Re: [Pear] help with Formbuilder and checkboxes
| From: | Justin Patrin | Date: | Tue, 17 Oct 2006 19:55:41 +0000 |
| Subject: | Re: [Pear] help with Formbuilder and checkboxes | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25489@lists.php.net to get a copy of this message | ||
On 10/17/06, Marco Sottana <marco.sottana@q-web.it> wrote:
marco schrieb:What you're asking for is normally called a SET and this isn't supported. However, you would get the exact same thing using crossLinks. To do this, create a table such as: checkboValue with fields id and name. I'm assuming you have a table named record with an id in it as well. You then set up a table names record_checkboxValues with fields checkboxValue_id and record_id which link to the checkboxValue table and record table. In the record DO you set: var $fb_crossLinks = array(array('table' => 'record_checkboxValue')); in the checkboxValue DO you set: var $fb_linkDisplayFields = array('name'); Then you have what you're looking for. For an example see: http://pear.reversefold.com/example/?table=movie&record=4 The Songs section is a crossLink (although it is also using crossLinkExtraFields). If you'd like source (may notbe fully up to date): http://pear.reversefold.com/example/source/example.tgz -- Justin PatrinHi 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[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 listso if i generate []labelA []labelB []labelC []labelD and i check A,Ci save in my field "valueA,ValueC" please help me.. i just send my request of help in forum.. but nobody answer me