Re: HTML_QuickForm_Controller and setDefaults
| From: | Kim Fredenberg | Date: | Wed, 13 Sep 2006 16:48:03 +0000 |
| Subject: | Re: HTML_QuickForm_Controller and setDefaults | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25127@lists.php.net to get a copy of this message | ||
Alexey Borzov wrote:
> I've gone through the code with a debugger and now I am positive that it
> is a bug in QF_Controller.
>
> When running special case code to check form-pages that weren't seen by
> users (lines 243-259 of Controller.php), such forms erroneously consider
> themselves submitted. Thus defaults for checkboxes and (probably)
> multiple selects are not used.
The behaivour is indeed very odd!
If I have the following code where sDate and eDate are textfields and
open_allyear is a checkbox, the the checkbox does get checked without
visiting the page:
-----------------------
$page2 = & new EventPage2('page2');
$page2->setDefaults(
array(
'sDate'=>date('d.m.Y',$event->getstartDate()),
'eDate'=>date('d.m.Y',$event->getendDate())
)
);
$page2->setDefaults(
array(
'open_allyear'=>1
)
);
-----------------------
If I do the following:
-----------------------
$page2 = & new EventPage2('page2');
$page2->setDefaults(
array(
'open_allyear'=>1
)
);
-----------------------
The the checkbox doesn't work!
From what I understood I can call the setDefaults several times since
the arrays get merged, don't they.
Very confusing...
Kim