Re: QuickForm problem
| From: | Bertrand Mansion | Date: | Fri, 02 Jan 2004 16:33:26 +0000 |
| Subject: | Re: QuickForm problem | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-9913@lists.php.net to get a copy of this message | ||
<cesare@ngi.it> wrote :
> Alle 13:58, venerdì 2 gennaio 2004, Bertrand Mansion ha scritto:
>> Why don't you use setDefaults() to set your hidden field value too.
>> Or even better, setConstants() as these values are probably not
>> modifiable (unless you use them in a javascript).
>
> This script is used to change the values of a form submitted previously.
> I get the old values from the db, then I use setDefaults() to fill in
> the form. The hidden value is used just as a marker to tell the script
> to update the values in the db.
>
>> I think there must be a problem somewhere else in your script where
>> you set the hidden field value to an empty value. But I can only
>> guess...
>
> It shouldn't be so, here's the snippet:
The validate() line looks weird here... But that's up to you, it depends
whether you are validating the form before showing it or validating another
form.
> 1 if (!$form->validate()) {
Did you try this instead ?
$defaults = $tblSegn->recdData + array('azione' => 'Modifica',
'id'
=> $_REQUEST['id']);
$form->setDefaults($defaults);
$form->addElement('hidden', 'azione');
$form->addElement('hidden', 'id');
> 6 $form->addElement('button', 'indietro', 'Indietro',
> 'onclick="javascript:history.back()"');
>
> 7 $tpl =& new HTML_Template_ITX('./tpl');
> 8 $tpl->loadTemplateFile('form_adm.html', TRUE, FALSE);
>
> 9 $renderer =& new HTML_QuickForm_Renderer_ITStatic($tpl);
> 10 $renderer->setRequiredTemplate('<span class="required">** </
> span>{label}');
> 11 $renderer->setErrorTemplate('<span class="error">{error}</
> span><br>{label}');
>
> 12 $form->accept($renderer);
> 13 $tpl->show();
> }
>
> This works. If I change lines 3 and 4 to
>
> $form->addElement('hidden', 'azione', 'Modifica');
Might be related to some other value overriding 'azione' value or
REGISTER_GLOBALS stuff or something else. BTW, I recommend using
setConstants() for hidden fields values.
> I find an empty hidden field in the form (value=""). There are no
> setElement() method calls, nor any other reference to 'azione'.
>
> Thanks for the hints, though :)
>
> Ciao
> ce