PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_QuickForm » Bug #2850

radio buttons do not fill when there is an error

Details

Submitted2004-11-29 13:29 UTC
Fromjim at whatifnet dot com
StatusBogus
PackageHTML_QuickForm
PHP Version4.3.8
OSLinux (Fedora Core 2)
Roadmaps(Not assigned)

Comments

[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.

[2004-11-29 16:26 UTC] jim at whatifnet dot com

I see, thank you for your time!