Zend Framework: The form filter I am using is not filtering!

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-06-16T18:19:44Z Indexed on 2010/06/16 18:22 UTC
Read the original article Hit count: 244

Filed under:
|
|

So I have a form that is using the Zend_Filter_Null filter. When I call it directly, it works:

$makeZeroNull = new Zend_Filter_Null();
$null = $makeZeroNull->filter('0');
//$null === null

However, when I try to add it to an element in my form, it doesn't filter the value when I call getValue().

class My_Form extends Zend_Form {
    public function init() {
        $makeZeroNull = new Zend_Filter_Null();
        $this->addElement('text', 'State_ID', array('filters' => array($makeZeroNull)));
    }
}

//in controller
if ($form->isValid($_POST)) {
    $zero = $form->State_ID->getValue();
    //getValue() should return null, but it is returning 0
}

What is going on? What am I doing wrong?

© Stack Overflow or respective owner

Related posts about php

Related posts about zend-framework