Re: Quickform suggestion

From: Date: Tue, 22 Apr 2003 13:44:51 +0000
Subject: Re: Quickform suggestion
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-15326@lists.php.net to get a copy of this message
<wolff@21st.de> wrote : > Here, one has to first define an element with addElement(), but > there´s no possibility to define things like the size, multiselect or > other options right away. To do that, one has to retrieve the freshly > created element from the form object, and make some additional > manipulations - why not add some more parameters on object creation? > > Same goes for validation rules... I have to call addRule() on each > field again which I want to have validated... okay, it works, and it´s > logical as well, but does it look nice? I think it can really clutter > your code when dealing with complex forms. > > In OOH_Form, I can define all those things in one go: > > $form->addElement(array('type' => 'text', > 'name' => 'elName', > 'size' => 40, > 'label' => 'Label:', > 'value' => 'some value', > 'minlength' => 2, > 'length_e' => 'Enter at least 2 chars', > 'accesskey' => 'e' > ) > ); Hi Markus, $form->addElement('text', 'elName', 'Label:', array('size' => 40)); You can use as much attributes you want, they are parsed by HTML_Common. You could also do this, HTML_Common knows how to handle it: $form->addElement('text', 'elName', 'Label:', 'size=40 maxlength=40'); As you can see, it's more flexible... And it allows you to define an array of attributes that you can reuse in other elements declaration. Rules, filters are stored in the main form object because they don't mean anything for me outside of the form object scope. Bertrand Mansion Mamasam

« previous php.pear.dev (#15326) next »