2008年8月8日星期五

[fw-mvc] Zend_Form Filters, my error or Bug?

I will put a very simple example

form.ini
;GLOBAL FILTER RULES
[global]
elementFilters.trim.filter = "StripTags"

//EmployeeForm.php
class EmployeeForm extends Zend_Form
{
public function init()
{
$this->setName('Employee');
$this->setMethod('post');
$element1 = new Zend_Form_Element_Text('emp_name', array(
'attribs' => array('size'=>'25','maxlength'=>'30'),
'required' => true,
'label' => 'Name' ,
'filters' => array('StringTrim') // filter fails
));
$this->addElements(array('$element1'));
$this->addElement('submit', 'test', array('label' => 'test'));

}
}

//EmployeeController.php
class EmployeeController extends Zend_Controller_Action
{
public function testAction(){

$config = new Zend_Config_Ini('/config/form.ini');
$form = new $form;
$form->setConfig($config->global);
$this->view->form = $form;

if ($this->_request->isPost()){

var_dump($form->getValues());
}
}

}

//var_dump
["emp_name"]=>string(9) "my text " // The filter "StringTrim" does not
work


Apparently this is my INI file overwriting

He sought an alternative solution, using addFilter, but there is another way
to do it?

--
View this message in context: http://www.nabble.com/Zend_Form-Filters%2C--my-error-or-Bug--tp18895969p18895969.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: