On Thu, Jun 23, 2011 at 3:31 PM, James Ganong <[email protected]>wrote:
> I have taken the approach Sergey mentions on a few different forms. It is > by > far the easiest method. The only drawback is that you have to impose a max > number of allowed dynamic fields. In most cases this is a good thing as you > probably don't want to allow anyone to add 100+ of any field. > > An alternative is to pass the number of dynamic fields desired to the form > object when it is created. This way you can still use the built in form > validation. Then on the front end side, you would need to use javascript to > clone the dynamic field when a button is clicked (ex: "add email"), or you > would need to reload the page each time you need to add a field to recreate > the form. This method is much trickier. > > Don't know if this is considered the best of practices, but sometimes in my Zend_Form's init(), I examine the request parameters by going Zend_Controller_Front::getInstance()->getRequest() and apply validation logic depending on who they are and what they are trying to do. In your case it seems like you could add as many elements (and their validators and filters) as you need and no more by doing something like that. -- David Mintz http://davidmintz.org/ It ain't over: http://www.healthcare-now.org/
