Aims. We aim to study the effect of a cosmologically motivated gas infall law for the formation of a massive elliptical galaxy in order to understand its impact on the formation of spheroids. Methods. We replace the empirical infall law of the model by Pipino & Matteucci with a cosmologically derived infall law for the formation of an elliptical galaxy. We compare our predictions with observations. We also compare the obtained results with those of Pipino & Matteucci.Results. We computed models with and without galactic winds; we found that models without wind predict a too large current SNIa rate. In particular, the cosmological model produces a current SNIa value which is about ten times higher than the observed values. Moreover models without wind predict a high current SNII rate, too large even if compared with the recent GALEX data. The predicted SNII rate for the model with wind, on the other hand, is too low if compared with the star formation histories given by GALEX. The mean value for the [Mg/Fe] ratio in the dominant stellar population of the simulated galaxy, as predicted by the cosmological model, is too low if compared to observations. This is a very important result indicating that the cosmological infall law is in contradiction to the chemical evolution. Conclusions. A cosmologically derived infall law for an elliptical galaxy cannot reproduce all the chemical constraints given by observations. The problem resides in the fact that the cosmologically derived infall law implies a slow gas accretion with a consequent star formation rate active for a long period. In this situation low [Mg/Fe] ratios are produced for the dominant stellar population in a typical elliptical, at variance with observations.