PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » HTML_QuickForm_Controller » Bug #5625

Fall to defaults using multiple choice selects

Details

Submitted2005-10-07 20:39 UTC
Fromanibal dot pacheco at dinama dot gub dot uy
StatusDuplicate
PackageHTML_QuickForm_Controller
PHP Version4.4.0
OSDebian GNU/Linux
Roadmaps(Not assigned)

Comments

[2005-10-07 20:39 UTC] anibal dot pacheco at dinama dot gub dot uy

Description:
------------
When you use a 'select' element with multiple choice and a default value, this default value is setted when you select nothing and browse the pages of the form and come back.

I think common sense tells us that when we come back to the page that has the select list nothing must be selected for us.

Test script:
---------------
<?php

require_once 'HTML/QuickForm/Controller.php';

session_start();

class Page1 extends HTML_QuickForm_Page{
function buildForm(){
$this->_formBuilt = true;
$this->addElement('text','tstText','Does not matter');
$this->addElement('submit',$this->getButtonName('next'), 'next >>');
}
}

class Page2 extends HTML_QuickForm_Page{
function buildForm(){
$this->_formBuilt = true;
$sel =& HTML_QuickForm::createElement('select','tstSel','Please select:',array('One','Two','Three'));
$sel->setMultiple(true);
$sel->setSize(3);
$this->addElement($sel);
$this->addElement('submit',$this->getButtonName('back'), '<< Back');
$this->addElement('submit',$this->getButtonName('next'), 'Finish');
$this->setDefaults(array('tstSel'=>array(0)));
}
}

$cont =& new HTML_QuickForm_Controller('myForm');
$cont->addPage(new Page1('pageone'));
$cont->addPage(new Page2('pagetwo'));
$cont->run();

?>

Expected result:
----------------
If I de-select the default value in the first time page two appear "blanking" the selections, I expect that when I come back to this page nothing is selected.

Actual result:
--------------
When I come back, the default value is selected.