SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member spheroid2007's Avatar
    Join Date
    Oct 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Pear QuickForm - Group text field and checkbox on same line

    I'm tweaking a form built with Pear QuickForm. Currently, I have checkboxes created based on the items in a database table:

    PHP Code:
       $altselect =& $form->addElement('altselect''item_id''Select a value:'$items_arr); 
       
    $altselect->setMultiple(true); // Turns radio buttons into checkboxes
       
    $altselect->setIncludeOther(false); // Sets "Other" textfield to allow other values to be entered 
    This will output the checkboxes one per line and works great. Now, how could I:
    1. Have two input (text field) boxes per line to set values for each checked item.
    2. Have 2 or 3 columns instead of only displaying one grouping per line.


    Currently for each checkbox, the html is outputting the field name for the checkboxes as "item_id[]" which works great so I can create a new record in one db table, and then add the selected options into a lookup table. I'm just not sure on how it will work when adding the other text fields in the grouping. Ideally this is how the portion of the table will look:

    Code:
    From: [ TEXT INPUT A ] To: [ TEXT INPUT B ]  - [  ] List item 1      From: [ TEXT INPUT A ] To: [ TEXT INPUT B ] -  [  ] List item 25
    From: [ TEXT INPUT A ] To: [ TEXT INPUT B ] -  [  ] List item 2      From: [ TEXT INPUT A ] To: [ TEXT INPUT B ] -  [  ] List item 26
    ...
    From: [ TEXT INPUT A ] To: [ TEXT INPUT B ] -  [  ] List item 24
    etc...
    Last edited by spheroid2007; Aug 7, 2007 at 11:48. Reason: Edited to show list in 2 columns

  2. #2
    SitePoint Member spheroid2007's Avatar
    Join Date
    Oct 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When using the Group function I can get two input fields next to the first checkbox in the array (checkboxes come from an array of items found in the db). But the remaining checkboxes don't have input fields.

    Code:

    PHP Code:
       $from = &HTML_QuickForm::createElement('text'''null, array('size' => 4'maxlength' => 3));
       
    $to = &HTML_QuickForm::createElement('text'''null, array('size' => 4'maxlength' => 3));
       
    $altselect = &HTML_QuickForm::createElement('altselect'''null$item_arr);
       
    $altselect->setMultiple(true); // Turns radio buttons into checkboxes
       
    $altselect->setIncludeOther(false); // Sets "Other" textfield to allow other values to be entered 
       
    $form->addGroup(array($from$to$altselect), 'itemyears''Item:'' '); 
    It outputs something like:

    [ field1 ] [ field2 ] [ ] Checkbox text
    [ ] Checkbox 2 text
    ...
    etc...

    The code it outputs is:

    Code:
    <input size="4" maxlength="3" name="itemyears[0]" type="text" /> <input size="4" maxlength="3" name="itemyears[1]" type="text" /> 
    <input name="itemyears[2][]" type="checkbox" value="11" id="qf_c10d7f" /><label for="qf_c10d7f">ITEM 1</label><br />
    <input name="itemyears[2][]" type="checkbox" value="19" id="qf_caa433" /><label for="qf_caa433">ITEM 2</label><br />


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •