FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=18787&edit=1

ID: 18787
Comment by: leonard-php-bugs@ottolander.nl
Reported By: leonard-php-bugs at ottolander dot nl
Summary: Can't set label on group elements
Status: Open
Type: Bug
Package: HTML_QuickForm2
Operating System: Linux
Package Version: 0.6.0
PHP Version: Irrelevant
Roadmap Versions:
New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[2011-09-05 15:54:28] leonardjo

Description:
------------
The example code in
http://pear.php.net/manual/en/package.html.html-quickform2.qf-migration.php
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".

------------------------------------------------------------------------

Search Discussions

  • Borz_off at Sep 6, 2011 at 6:21 am
    Edit report at http://pear.php.net/bugs/bug.php?id=18787&edit=1

    ID: 18787
    Updated by: borz_off@cs.msu.su
    Reported By: leonard-php-bugs at ottolander dot nl
    Summary: Can't set label on group elements
    -Status: Open
    +Status: Analyzed
    -Type: Bug
    +Type: Documentation Problem
    Package: HTML_QuickForm2
    Operating System: Linux
    Package Version: 0.6.0
    PHP Version: Irrelevant
    Roadmap Versions:
    New Comment:

    -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.


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-09-05 16:36:03] leonardjo

    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-05 15:54:28] leonardjo

    Description:
    ------------
    The example code in
    http://pear.php.net/manual/en/package.html.html-quickform2.qf-migration.php
    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".

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedSep 5, '11 at 2:35p
activeSep 6, '11 at 6:21a
posts2
users2
websitepear.php.net

2 users in discussion

Borz_off: 1 post Leonard-Php-Bugs: 1 post

People

Translate

site design / logo © 2022 Grokbase