I've recently started using Zend_Form and like it quite a bit, but I am having issues with setting values for form elements. I like extending Zend_Form and creating the form in the init method, but if I am creating a form where people can edit information that is already in the database I don't see a good way to pass that information to the form class. I could just use isValid to populate it, but that doesn't seem right since I don't actually want to validate anything. After all, if the data already exists it should be valid. It seems that a setValues method would be better but I don't see any such method.
What I'm considering is adding a static variable to my form classes which will contain the data and a static method which I would pass that data to. That method would then set the variable and instantiate the class. When setting the form elements in the init method it would check if values exist in the variable and use them. Then the method would return the form class instance. I think this is a fine work around, but I think it would be better if Zend_Form had a method that could set all values without having to validate it as well. So basically, I am looking to do something like this: $formObj = Form::getForm($arrayOfValues); When I would rather do this: $formObj = new Form; $formObj->setValues($arrayOfValues); Am I missing something or does that functionality just not exist? Mark -- Have fun or die trying - but try not to actually die.
