Hello, Basically you can use Zend_Form::setDefaults(array $defaults) to populate form with data retreived from your model as an array, else (if you are using Doctrine for example, or by some other reason you can't use model's data with setDefaults() directly) you can extend Zend_Form to be able "read" your models, something like this: http://blog.ixti.ru/archives/263
2010/5/16 tonystamp <[email protected]>: > > Hello > > I'm wondering about the best practice for populating forms with model data. > > I've been creating my forms with an optional array parameter in the > constructor for the model to be passed in to the form class. If the model is > present, the form is loaded with the models data. This is done from within > the form class that extends zend_form. > > I was wondering if this is the best way to create forms, or perhaps the form > should be empty of model data and a view helper populates the form with the > data from the model? Or any other way that can achieve a better separation? > > > -- > View this message in context: > http://zend-framework-community.634137.n4.nabble.com/populating-form-from-model-tp2218378p2218378.html > Sent from the Zend Framework mailing list archive at Nabble.com. > -- Sincerely yours, Aleksey V. Zapparov A.K.A. ixti FSF Member #7118 Mobile Phone: +34 617 179 344 Homepage: http://www.ixti.ru JID: [email protected] *Origin: Happy Hacking!
