Hi Matthew
I've just created a small feature request for Zend_Form to add an
'init()' method to the base class. I'd imagine it implemented the same
way as it's used for Zend_Controller_Action and Zend_Db_Table, as a
'safe' way to add behaviours and logic to a form model when
subclassing Zend_Form. Ideally it would be called as the last step in
the base __construct method.
So instead of:-
class My_Form_AccountSkills extends Zend_Form
{
public function __construct($options = null)
{
parent::__construct($options); // Important!
$username = $this->createElement('text', 'username');
$username->addValidator('alnum')
->addValidator('regex', false, array('/^[a-z]+/'))
->addValidator('stringLength', false, array(6, 20))
->setRequired(true)
->addFilter('StringToLower');
...etc...
}
}
...this seems cleaner and more relevant as I rarely need to set the
default $options argument...
class My_Form_AccountSkills extends Zend_Form
{
public function init()
{
$username = $this->createElement('text', 'username');
$username->addValidator('alnum')
->addValidator('regex', false, array('/^[a-z]+/'))
->addValidator('stringLength', false, array(6, 20))
->setRequired(true)
->addFilter('StringToLower');
...etc...
}
}
Regards
--
Simon Mundy | Director | PEPTOLAB
""" " "" """""" "" "" """"""" " "" """"" " """"" " """""" "" "
202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654
4124
http://www.peptolab.com