开发者

$this->addElement('type', 'id', array('specs')) VS new Zend_Form_Element_Type('id');

开发者 https://www.devze.com 2023-04-10 01:50 出处:网络
What are the Pro\'s and Con\'s of: $this->addElement(\'type\', \'id\', array(\'specs\')) vs new Z开发者_如何学JAVAend_Form_Element_Type(\'id\');

What are the Pro's and Con's of:

$this->addElement('type', 'id', array('specs'))

vs

new Z开发者_如何学JAVAend_Form_Element_Type('id');

I think the second is preferable because more readable and offers auto-completion.


The Zend Framework provides this flexibility so that you can tailor the API to your needs. So, the answer is "it depends"...

In my opinion, the array interface could be prefereable if you get the form elements data from a configuration file (for instance, you might need to modify often the form elements during development or production of your application), while the object creation interface looks "cleaner" and is less error prone (you can get auto completion from your IDE, as you say).

Hope that helps,

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号