Re: Re: Your opinion about QuickForm2 API
| From: | Alexey Borzov | Date: | Mon, 16 Apr 2007 19:57:43 +0000 |
| Subject: | Re: Re: Your opinion about QuickForm2 API | ||
| References: | 1 2 | Groups: | php.pear.dev php.pear.general |
| Request: | Send a blank email to pear-dev+get-46260@lists.php.net to get a copy of this message | ||
Hi,
Gregory Beaver wrote:
I've honestly found the addElement() API to be difficult to work with in the past, so simplifying it would be a welcome change. However, I don't think "addElement" needs to exist in Quickform2. Have you considered an API similar to the following? <?php $form = new HTML_Quickform2; $form['action'] = '/path/to/action.php'; $form['method'] = 'post'; // or $form['attrs'] = array('action' => '/path/to/action.php', 'method' => 'post'); $g = $form->group['mygroup']; $g->text = array('name' => 'aText', 'size' => 50, 'default' => 'whatever'); $g->select = array('name' => 'aSelect', 'options' => array(...)); // or $g->text(array('name' => 'aText', 'size' => 50))With all due respect, SimpleXML API which you seem to use as inspiration here uses addAttribute() and addChild() methods for adding attributes and child nodes, it doesn't work as shown above. ;) We considered something like that, but decided to go with DOM-like API for now. BTW, while you are here, Bertrand is having some problems generating docs for QF2: http://quickform.mamasam.com/docs/ The generation process seems to finish in the middle of writing files with no errors in the log. Try clicking the links and observe a bunch of 404s.->validate['regex'] = '/\w+/';$g->select(array('name' => 'aSelect', 'options' => array()) $select = $g->select['aSelect']; // or $form->select['aSelect']; $select->options['another'] = 1; $select->validate['custom'] = 'is_numeric'; ?>