Re: Your opinion about QuickForm2 API
| From: | David Coallier | Date: | Tue, 17 Apr 2007 10:51:36 +0000 |
| Subject: | Re: Your opinion about QuickForm2 API | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-46269@lists.php.net to get a copy of this message | ||
I would even make it:
$clickbutton =
$form->addElement('button', 'aButton')->setContent('Click
me')->setAttributes('onClick' => 'alert("Clicked!")');
On 4/17/07, Christoph Schiessl <c.schiessl@gmx.net> wrote:
On Apr 17, 2007, at 9:58 AM, Markus Ernst wrote: Alexey Borzov schrieb: [...]I cannot say I support setting variables and properties with arrays, it also have been the biggest thing that kept me away from QF for a long time. -- David Coallier, Founder & Software Architect, Agora Production (http://agoraproduction.com) 51.42.06.70.18I assume it is more consistent to always use an array and provide additional setters for all possible keys, so every element can be added in both ways: $form->addElement('button', 'aButton', array('content' => 'Click me', 'attributes' => array('onClick' => 'alert("Clicked!")'))); I don't like the idea of using arrays for the additional parameters. Element creation has always been a problem for me in QF1, because there were to many possible combinations of parameters to remember all of them. or: $clickbutton = $form->addElement('button', 'aButton'); $clickbutton->setContent('Click me'); $clickbutton->setAttributes('onClick' => 'alert("Clicked!")'); Like this, every public property can actually be set on element construction. Looks nice. I think that would be easier to use (and to remember). Also note that I suggest to use setContent() to define the preselected option rather than something like $option->setSelected () (which could be left as an alternative). It looks consistent to me to set the preselected value with the same method for all kinds of elements/groups, regardless of the way it looks in the generated HTML. So setContent() in a select box will result in setting the selected attribute, while it will set a value attribute if applied on a text field. Fully agree on that one. -- Markus -- PEAR Development Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Christoph SchiesslWhat's really being discussed is the following, will we make the "additional data" parameter that has different semantics from element to element always an array, so the first pair of calls above turns into $form->addElement('button', 'aButton', array('content' => 'Click me please')); $form->addElement('select', 'aSelect', array('options' => array ('1' => 'option 1', '2' => 'option 2'))); even though the elements in question will never need any additional data other than 'content' and 'options'.