[PEAR] help with FormBuilder and checkboxes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> marco schrieb:
>> [code]
>> function preGenerateForm()
>> {
>> $this->fb_preDefElements['alive'] =
>> 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=array();    $box[]=&
>> HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null,
>> '0',null,'0');     $box[]=&
>> HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null,
>> '1',null,'1');     $box[]=&
>> HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null,
>> '2',null,'2');     $this->fb_preDefElements['checkbox_intention'] =
>> $box;      }
>> [/code]
>> but this don't save correctly.. field called "checkbox_intention" is a 
>> 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 
>> 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 
> understand what you want to achieve. Please try to rephrase.
>
> If your problem is that the elements are not being properly grouped 
> together, try to put the array of elements into a QuickForm group:
>
> $group =& new HTML_QuickForm_group('checkbox_intention', 'Intention', 
> $box);
> $this->fb_preDefElements['checkbox_intention'] =& $group;
>
> See also:
> http://pear.php.net/manual/en/package.html.html-quickform.php#package.html.html-quickform.groups
>
> CU
>  Markus


Hallo Marcus,
Thanks a lot for your availability,

i update my code so :

[code]
function preGenerateForm() {
   $box=array();
   $box[]=& 
HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null, 
'0',null,'0');
   $box[]=& 
HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null, 
'1',null,'1');
   $box[]=& 
HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null, 
'2',null,'2');
   $group =& new HTML_QuickForm_group('checkbox_intention', 'Intention', 
$box);
   $this->fb_preDefElements['checkbox_intention'] =& $group;
}
[/code]

but it makes an error

[error]
Notice: Array to string conversion in /usr/share/php5/PEAR/DB/DataObject.php 
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, 
there's also some problemes, please help me another one

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux