Re: QFC and numeric indexes as element names in groups?
| From: | Bertrand Mansion | Date: | Mon, 01 Mar 2004 15:18:05 +0000 |
| Subject: | Re: QFC and numeric indexes as element names in groups? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-11033@lists.php.net to get a copy of this message | ||
<ignatius.reilly@free.fr> wrote :
> QFC does not seem to handle numeric indexes as I would expect in the
> following example:
>
> <?php
> require_once "HTML/QuickForm/Controller.php" ;
> require_once "HTML/QuickForm/Action.php" ;
>
> class Page1 extends HTML_QuickForm_Page
> {
> function buildForm()
> {
> $this->_formBuilt = true;
>
> $select = array(
> 1 => "me",
> 2 => "you"
> ) ;
> $data = array(
> 12 => 12000,
> 11 => 11000
> ) ;
>
> foreach ( $data as $key => $value ) {
> // Add a SELECT element
> $group[] =& $this->createElement( "select", $key, $value, $select ) ;
> }
> $this->addGroup( $group, "people", NULL, "<br/>" ) ;
>
> // QFC action element
> $this->addElement( 'submit', $this->getButtonName( 'next' ),
> 'Submit
> changes' ) ;
>
> }
> }
>
>
> class ActionProcess extends HTML_QuickForm_Action
> {
> function perform( &$page, $actionName ) {
> print_r( $GLOBALS['container'] ) ;
> die ;
> }
> }
>
> $wizard =& new HTML_QuickForm_Controller( '' ) ;
> $container =& $wizard->container() ;
>
> $wizard->addPage( new Page1( 'page1' ) ) ;
> $wizard->addAction( 'process', new ActionProcess() ) ;
> $wizard->run() ;
>
> ?>
>
> The indexes on group elements in the container are not 12 and 11 as I would
> expect, but 12 and 13.
>
> Does it mean one should abstain from using numeric values as indexes for
> group element names? That would be a pity!
Could you try with the CVS versions of both QuickForm and QFC as I have
tried to fix that by using our own array_merge method.
Please report if it works. Thanks,
Bertrand Mansion
Mamasam