>
> Also, it's recommended practice to override the (empty) init method in
> Zend_Form rather than the constructor:
>
> class SoftwareForm extends Zend_Form
> {
> public function init()
> {
> // Form initialisation as normal
> }
> }
>
couple of questions on this?
1) Where do I find out such recommended practices?
2) My own code breaks when I switch it to init() rather than the
constructor... changing this
public function __construct($options = null)
{
// Path setting for custom decorations
$this->addElementPrefixPath('MyApp_Form_Decorator',
'MyApp/Form/Decorator/',
'decorator');
// Path string for custom form elements
$this->addPrefixPath('MyApp_Form_Element',
'MyApp/Form/Element/',
'element');
$this->_setupTranslation();
parent::__construct($options);
$this->setAttrib('accept-charset', 'UTF-8');
$this->setDecorators(array(
'FormElements',
'Form'
));
}
to this:
public function init() {
{
// Path for custom decorations
$this->addElementPrefixPath('MyApp_Form_Decorator',
'MyApp/Form/Decorator/',
'decorator');
// Path string for custom form elements
$this->addPrefixPath('MyApp_Form_Element',
'MyApp/Form/Element/',
'element');
$this->_setupTranslation();
$this->setAttrib('accept-charset', 'UTF-8');
$this->setDecorators(array(
'FormElements',
'Form'
));
}
gives me errors because my paths aren't set early enough I think ('Plugin by
name MyPluginName was not found in the registry')
Am I missing something - it has me stumped as to why its not working. The
stack shows init() being called immediately after the parent constructor
...
#3 ...MyApp\library\Zend\Form.php(223): MyApp_Form_AuthorLogin->init()
#4 ...MyApp\application\controllers\AuthorController.php(7):
Zend_Form->__construct()
...
Any ideas?
--
View this message in context: http://www.nabble.com/need-help-with-Zend-Form-tp19512367p20034902.html
Sent from the Zend MVC mailing list archive at Nabble.com.
没有评论:
发表评论