I would like to add a filter to the text form element. The code is:
$this->addElement('text', 'product_amt', array(
'filters' => array('Digits'),
'required' => true )
);
The filter seems not work because when i type e.g. "78abc" the value stays unchanged in the filed when i press the form submit button. Moreover i get "78abc" not "78" as "product_amt" POST parameter.
The value coming from POST will be the value the user has entered in the input field. The filters are applied when you call
isValidon the form object:During the
isValidfunction, the value for each element is filtered as required (in this case into only Digits) then set as the elements' value before the elements'isValidfunction is called to make sure the value passes any validation (in this case 'isRequired' as you have set 'required' to true).Are you calling
isValidon your form?