Why does your init need access to the model? Maybe to populate a select element's options?
In that case, yeah, you'll probably have to set the model via the constructor. Konr On Fri, Jan 29, 2010 at 8:53 AM, David Mintz <[email protected]> wrote: > > > On Thu, Jan 28, 2010 at 10:49 PM, Konr Ness <[email protected]> wrote: > >> David, >> >> That's exactly how I do it. If my form needs an instance of the model I * >> always* have a setter for the model (instead of requiring the form to >> create it's own instance). >> >> I do this a lot for forms like user registration which needs to have a >> unique email address validator (which obviously needs access to the model to >> check the DB). [...] >> > > > Thanks. Just curious: do you call your setter every time, or have you > devised away to hand your model instance to your form's constructor? Because > I would like that database connection to be available to init(), which is > called by the constructor. > > If you say new My_Form(array('model' => $model')) I imagine that would work > but it would constrain your constructor to using arrays and not Zend_Config. > Then again, do we care? > > I guess another alternative is to add an optional second argument $model to > your subclass' constructor. > > > > -- > Support real health care reform: > http://phimg.org/ > > -- > David Mintz > http://davidmintz.org/ > > >
