Edit report at https://pear.php.net/bugs/bug.php?id=20990&edit=1
ID: 20990
Comment by: betrazivis@gmail.com
Reported By: betrazivis@gmail.com
Summary: Serverside group validation of single elements
Status: Bogus
Type: Bug
Package: HTML_QuickForm2
Operating System: Linux, CentOS
Package Version: 2.0.2
PHP Version: 5.6.16
Roadmap Versions:
New Comment:
Ok, now I understand. No serverside validation message by default on
grouped elements. I admit, it took me hours to understand how this
works.
Maybe this could be a feature in next releases ;)
Thank you.
Previous Comments:
------------------------------------------------------------------------
[2015-12-14 06:32:53] avb
-Status: Open
+Status: Bogus
That's not exactly a bug, but a shortcoming of default templates for
Default renderer. This is also documented:
https://pear.php.net/manual/en/package.html.html-quickform2.renderers.default.php#package.html.html-quickform2.renderers.default.groups
What happens is that the rule sets the error for grouped element (and
thus validation fails), but the error is not displayed as there is no
placeholder to do so.
------------------------------------------------------------------------
[2015-12-11 06:26:13] betrazivis_2
Description:
------------
Validation of elements inside a group is only possible with
CLIENT_SERVER flag, not only with SERVER.
Test script:
---------------
$form = new HTML_QuickForm2('Rulestest');
$fsGrouped = $form->addElement('fieldset')->setLabel('Validating grouped
elements');
$boxGroup = $fsGrouped->addElement('group', 'boxes')->setLabel('Check at
least two:');
$boxGroup->addElement('checkbox', null, array('value' =>
'red'))->setContent('<span style="color: #f00;">Red</span>');
$text = $boxGroup->addElement('text', 'testUsername', array('style' =>
'width: 200px;'))
->setLabel('Username (letters only):');
$boxGroup->addRule('required', 'Check at least of these', 1,
HTML_QuickForm2_Rule::SERVER);
$text->addRule('required', 'Text is required', null,
HTML_QuickForm2_Rule::SERVER);
$form->addElement('submit', 'testSubmit', array('value' => 'Send'));
$form->validate()
$renderer = HTML_QuickForm2_Renderer::factory('default');
$form->render($renderer);
// Output javascript libraries, needed for client-side validation
echo $renderer->getJavascriptBuilder()->getLibraries(true, true);
echo $renderer;
Expected result:
----------------
A validation result of $text like "CLIENT_SERVER".
Actual result:
--------------
No validation message.
------------------------------------------------------------------------