QuickForm w/Smarty: Defaults render when form has error

From: Date: Sat, 03 Jan 2004 11:50:55 +0000
Subject: QuickForm w/Smarty: Defaults render when form has error
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9926@lists.php.net to get a copy of this message
Hi, I've got one of those 5-hour head-scratchers: I'm using HTML_QuickForm in combo with HTML_QuickForm_Renderer_ArraySmarty to handle a sign-up form. I'm down to my last element -- a simple two item radio group -- and I'm having quite a bit of trouble with it. I finally have it rendering the way I'd like (when the form first loads), but there's a problem with the default value always rendering as selected when there's an error elsewhere on the form. The end result is that on form error, both items come back selected. Here's a couple code snippets: //Form and Smarty object already created by now setSignUpFormDefaults(); function makeFormElementRadio() { $radio[] = &HTML_QuickForm::createElement('radio', 'yes', 'yesLabel', NULL, '1'); $radio[] = &HTML_QuickForm::createElement('radio', 'no', 'noLabel', NULL, '0'); $this->form->addGroup($radio, 'radio', ''); } function setSignUpFormDefaults() { $this->form->setDefaults(array( 'radio' => '1')); } And then my smarty template just looks like this: <tr> <td>{$form.radio.yes.html}</td> <td>{$form.radio.yes.label}</td> </tr> <tr> <td>{$form.radio.no.html}</td> <td>{$form.radio.no.label}</td> </tr> If anyone is able to solve this, I promise to give you my first-born! Thanks, Tim

« previous php.pear.general (#9926) next »