views:

123

answers:

1

So I've determined that my validator does not get called when I filter the input value and turn zero into null.

$this->addElement('select', 'State_ID', array('label' => 'State', 'multiOptions' => $this->getStates(), 'validators' => array($requiredBasedOnCountry), 'filters' => array($makeZeroNull)));

The reason I am doing this is because I don't want to insert 0 into the database. When I call getValues() on the form, I don't want to have to change each one manually. But I want to also validate the input. How can I filter the value, and also validate it?

A: 

I'm not really sure what your validators or filters are, since you've only shared that they're two variables, without saying what they are.

That said, Zend_Filter_Null will probably be what you're looking for.

http://framework.zend.com/manual/en/zend.filter.set.html

Dan G