Hi Matthew,

I seem to have a found a couple is simple bugs in revision 155.
Zend_Form_Element_Select and 
Zend_Form_Element_Radio don't parse due to '.php' in the class declarations.

On a more tricky issue I'm a little stuck dealing with form input where the
field is optional. I note your test.php contains addValidator(new
Zend_Validate_NotEmpty()) which is clear enough, but how might I validate a
Zend_Form_Element when the input is to be considered optional for it?

For instance:

class TestForm extends Zend_Form_Abstract
{
    public function __construct()
    {
        $myNumber = new Zend_Form_Element_Text('my_number');
        $myNumber->setLabel('My Number')
                 ->addValidator(new Zend_Validate_Int());
        $this->addElement($myNumber)
             ->addElement(new Zend_Form_Element_Submit('save'));
    }
}
$view = new Zend_View();
$view->addHelperPath(dirname(dirname(__FILE__)) .
'/library/Zend/View/Helper', 'Zend_View_Helper');
$form = new TestForm();
$form->setView($view);
$form->populate(array(
    'my_number' => '',
));
echo $form->render($view), "\n\n";

Produces "'' does not appear to be an integer" but I want the field to be
optional.

Let's say the my_number column in my DB is a nullable and the currently the
relevant row actually does contain a number but the user wants to simply
wipe it. I think if the user blanks out the form field and passes an empty
string as a result I should interpret that as needing to replace the number
in the DB with a null value to clear it, but it looks like I'm not even
getting passed validation right now.

Does this make sense? Perhaps I'm not approaching the problem correctly.
Also Zend_Form doesn't appear to make use of Zend_Filter_Input unless I
missed it. Could that be a factor here?


Regards,
Mark



Matthew Weier O'Phinney-3 wrote:
> 
>     http://framework.zend.com/svn/laboratory/Zend_Form
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_Form-tf4719410s16154.html#a14185833
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to