Re: QuickForm problems setting defaults
| From: | Justin Patrin | Date: | Wed, 13 Apr 2005 22:42:55 +0000 |
| Subject: | Re: QuickForm problems setting defaults | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18743@lists.php.net to get a copy of this message | ||
On 4/13/05, Mark Steudel <msteudel@panicware.com> wrote:
> I was hoping someone would take a look and see what I'm doing wrong when
> setting the defaults values for a form:
>
> $form = new HTML_QuickForm('addproducts');
>
> $form->addElement('header', null, 'Edit Products');
>
> $form->addElement('select', "upc$i", 'UPC:', $selectArray,
> array ( 'id' =>
> "upc$i", 'onChange' => "addText(upc$i);"));
>
> $form->addElement('text', "distpart$i", 'Distributor Part:',
> array('size' =>
> 40, 'maxlength' => 255 ));
>
> $form->addElement('text', "quantity$i", 'Quantity:',
> array('size' => 40,
> 'maxlength' => 255 ));
>
> $form->setDefaults ( array('upc$i' => $objData->upc, 'distpart$i'
> =>
> $objData->distpart, 'quantity$i'=>$objData->quantity));
>
> $objData is the the results of a mysql_fetch_object(). I've tested that the
> data is getting into to $objData by doing a print_r( $objData ); right
> before I create the form, sample results:
>
> stdClass Object ( [id] => 2 [orderid] => 1 [upc] => 852362000125 [pwipart]
> => 0 [distpart] => 0 [quantity] => 0 [description] => )
>
You're using single quotes in your setDefaults call. Either change it
to double quotes for the ones that include $i or do: 'upc'.$i (I like
this way better).
--
Justin Patrin