Re: Re: QuickForm w/Smarty: Defaults render when form haserror

From: Date: Sun, 04 Jan 2004 00:38:27 +0000
Subject: Re: Re: QuickForm w/Smarty: Defaults render when form haserror
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9942@lists.php.net to get a copy of this message
<timw@guyfinley.com> wrote : >> Hi Tim, >> >> Can you confirm your problem with the last release 3.2.1 ? >> >> Bertrand > > > Hi Bertrand, > > I installed the latest QuickForm version after seeing the notice this > morning about there being Smarty and radio group bugs in the old one. The > problem has gotten better, but there's still something strange happening. > > First, I should mention that one of the hurdles is that I'm trying to use a > table to split up the presentation of the radio element and the label. > > There's several problems (though probably one cause): > > 1) When there's a form error, the option the user chooses from the radio > group doesn't get displayed -> it only gets displayed if it matches the > default value (which tells me the value probably isn't getting back to the > validator at all). > 2) The output of the form doesn't reflect the value for the radio option > selected. > 3) Here's the best I've been able to do to get it to render correctly: > <input name="KeyListStatusID[]" value="1" type="radio" > id="qf_862814" > checked="checked" /> > > See that name array KeyListStatusID[]? --> I can't get that guy to show up > like a standard group name: KeyListStatusID. > > Currently here's the best I've been able to come up with for adding the > elements to the form: (I've tried every variation I can come up with): > > $radio[] = &HTML_QuickForm::createElement('radio', '', 'Label > message1', '', > '1'); > $radio[] = &HTML_QuickForm::createElement('radio', '', 'Label > message2', '', > '3'); > $this->form->addGroup($radio, 'KeyListStatusID', ''); You should add your radios like this : $radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Label message1', '1'); $radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Label message2', '3'); $form->addGroup($radio, 'KeyListStatusID'); Otherwise, you create an array in your html code that will be parsed by php when it is posted and that's not what you want. > Setting the defaults looks like this: > > function setSignUpFormDefaults() > { > $this->form->setDefaults(array( 'KeyListStatusID' => '1' )); > } That's ok. Thanks for the nice comments :) Bertrand Mansion Mamasam

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