[PEAR] help with FormBuilder and checkboxes
am 17.10.2006 11:09:10 von Marco Sottana------=_NextPart_000_001C_01C6F1DC.AB97F6C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
> marco schrieb:
>> [code]
>> function preGenerateForm()
>> {
>> $this->fb_preDefElements['alive'] =3D
>> HTML_QuickForm::
>> createElement('advcheckbox','alive','Ali
>> ve',null,null,$this->alive);
>> }
>> [/code]
>> this code generate a only one checkbox..
>> i would like to generate a list of checkbox so i tryed [code]
>> function preGenerateForm(&$fb) { $box=3Darray(); $box[]=3D&
>> =
HTML_QuickForm::createElement('advcheckbox','checkbox_intent ion',null,
>> '0',null,'0'); $box[]=3D&
>> =
HTML_QuickForm::createElement('advcheckbox','checkbox_intent ion',null,
>> '1',null,'1'); $box[]=3D&
>> =
HTML_QuickForm::createElement('advcheckbox','checkbox_intent ion',null,
>> '2',null,'2'); $this->fb_preDefElements['checkbox_intention'] =3D
>> $box; }
>> [/code]
>> but this don't save correctly.. field called "checkbox_intention" is =
a=20
>> varchar(200) and a i would like
>> to save as a list
>> so if i generate []labelA []labelB []labelC []labelD and i check =
A,C=20
>> i save in my
>> field "valueA,ValueC"
>> please help me.. i just send my request of help in forum.. but nobody
>> answer me
>
> Hi Marco,
>
> I read your code and your description, and I am still not sure I=20
> understand what you want to achieve. Please try to rephrase.
>
> If your problem is that the elements are not being properly grouped=20
> together, try to put the array of elements into a QuickForm group:
>
> $group =3D& new HTML_QuickForm_group('checkbox_intention', =
'Intention',=20
> $box);
> $this->fb_preDefElements['checkbox_intention'] =3D& $group;
>
> See also:
> =
http://pear.php.net/manual/en/package.html.html-quickform.ph p#package.htm=
l.html-quickform.groups
>
> CU
> Markus
Hallo Marcus,
Thanks a lot for your availability,
i update my code so :
[code]
function preGenerateForm() {
$box=3Darray();
$box[]=3D&=20
HTML_QuickForm::createElement('advcheckbox','checkbox_intent ion',null,=20
'0',null,'0');
$box[]=3D&=20
HTML_QuickForm::createElement('advcheckbox','checkbox_intent ion',null,=20
'1',null,'1');
$box[]=3D&=20
HTML_QuickForm::createElement('advcheckbox','checkbox_intent ion',null,=20
'2',null,'2');
$group =3D& new HTML_QuickForm_group('checkbox_intention', =
'Intention',=20
$box);
$this->fb_preDefElements['checkbox_intention'] =3D& $group;
}
[/code]
but it makes an error
[error]
Notice: Array to string conversion in =
/usr/share/php5/PEAR/DB/DataObject.php=20
on line 1218
[/error]
[input]
Intention 0 1 2
[/input]
even if i check 0 and 1 and 2 in output
[output]
Intention [ ]0 [ ]1 [x]2
[/output]
Your suggest is near to the correct code version but as you've seen up,=20
there's also some problemes, please help me another one
------=_NextPart_000_001C_01C6F1DC.AB97F6C0--