Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.2.16

Bug #2850 radio buttons do not fill when there is an error
Submitted: 2004-11-29 13:29 UTC
From: jim at whatifnet dot com Assigned:
Status: Bogus Package: HTML_QuickForm
PHP Version: 4.3.8 OS: Linux (Fedora Core 2)
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 35 - 13 = ?

 
 [2004-11-29 13:29 UTC] jim at whatifnet dot com
Description: ------------ When a form is created with radio buttons and is filled out incorrectly and submitted, the radio buttons do not auto fill if they were selected when the form was submitted. When a radio button is select and the form is submitted, no radio button in that group will be selected. When no radio button is selected and the form is submitted, the last radio button in that group will be selected. Reproduce code: --------------- <?php require_once 'HTML/QuickForm.php'; $form = new HTML_QuickForm('firstForm', 'post'); $form->addElement('header', null, 'This is a header'); $form->addElement('text', 'firstname', 'First Name:', array('maxlength' => 255)); $form->addElement('text', 'lastname', 'Last Name:', array('maxlength' => 255)); $form->addElement('radio', 'radio', 'Select one:', "Radio Testing"); $form->addElement('radio', 'radio', '', "Radio Test2"); $form->addElement('submit', null, 'Submit'); $form->applyFilter('firstname', 'trim'); $form->addRule('firstname', 'Please enter your first name', 'required', null); if ($form->validate()) { echo 'success'; }else{ echo $form->toHtml(); } ?> Expected result: ---------------- I expect that when a radio button is selected and a form is submitted and it does not validate, that the correct radio button will still be selected. Actual result: -------------- When a radio button is selected and the form does not validate, the correct radio button will not be selected.

Comments

 [2004-11-29 15:59 UTC] avb
The error is in your code: you don't set values for your radio buttons.
 [2004-11-29 16:26 UTC] jim at whatifnet dot com
I see, thank you for your time!