Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.0.2

Doc Bug #18787 Can't set label on group elements
Submitted: 2011-09-05 19:54 UTC
From: leonardjo Assigned: avb
Status: Closed Package: HTML_QuickForm2 (version 0.6.0)
PHP Version: Irrelevant OS: Linux
Roadmaps: (Not assigned)    

 [2011-09-05 19:54 UTC] leonardjo (Leonard den Ottolander)
Description: ------------ The example code in under "Adding elements to the form" suggests that labels can be added to group elements. However, the code in the example does not actually add labels to the text elements. Also using ->addLabel('First') does not seem to do the trick. No syntax errors with either approach, but no labels are written. Test script: --------------- <?php $fieldset = $form->addFieldset('personal')->setLabel('Personal Information'); $group = $fieldset->addGroup('name')->setLabel('Name:')->setSeparator(', '); $group->addText('first', 'size=10', array('label' => 'First')); $group->addText('last', 'size=10', array('label' => 'Last')); ?> <?php $fieldset = $form->addFieldset('personal')->setLabel('Personal Information'); $group = $fieldset->addGroup('name')->setLabel('Name:')->setSeparator(', '); $group->addText('first', 'size=10')->setLabel('First'); $group->addText('last', 'size=10')->setLabel('Last'); ?> Expected result: ---------------- The labels "First" and "Last" showing. Actual result: -------------- No labels "First" and "Last".


 [2011-09-05 20:36 UTC] leonardjo (Leonard den Ottolander)
Just figured out this is just an error in the example (doc bug). The correct identifier to set the "label" is 'content' not 'label'; <?php $fieldset = $form->addFieldset('personal')->setLabel('Personal Information'); $group = $fieldset->addGroup('name')->setLabel('Name:')->setSeparator(', '); $group->addText('first', 'size=10', array('content' => 'First')); $group->addText('last', 'size=10', array('content' => 'Last')); ?> works as expected.
 [2011-09-06 12:22 UTC] avb (Alexey Borzov)
-Status: Open +Status: Analyzed -Type: Bug +Type: Documentation Problem
The example code is correct. However, default templates of default Renderer do not have placeholders for labels of grouped elements so they are not output. Need documentation on how to customize form output. Currently you can check controller/wizard.php example installed with the package, it shows adding labels to grouped elements among other things.
 [2012-02-18 19:33 UTC] avb (Alexey Borzov)
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: avb
Templates for grouped elements are now mentioned in renderer docs: