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

Bug #20985 Empty rules is not supported for group containing group
Submitted: 2015-11-18 19:07 UTC
From: stav Assigned:
Status: Open Package: HTML_QuickForm2 (version 2.0.2)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2015-11-18 19:07 UTC] stav (Bastien Blanchard)
Description: ------------ * Create a main group * Create a child group of main group * add a validation rules 'empty' to main group Validation generate a warning and don't fail if child group is non empty Test script: --------------- $form = new HTML_QuickForm2('garage'); /** @var HTML_QuickForm2_Container_Group $carGroup */ $carGroup = $form->addElement('group', 'car'); /** @var HTML_QuickForm2_Container_Group $motorGroup */ $motorGroup = $carGroup->addElement('group', 'motor'); $motorGroup->addElement('text', 'name'); $nameField = $carGroup->addElement('text', 'name'); $carGroup->addRule('empty'); $nameField->addRule('nonempty', 'name is required') ->or_($carGroup->createRule('empty')); $_POST['car'] = array('motor'=>array('name'=>'example')); $form->addDataSource(new HTML_QuickForm2_DataSource_SuperGlobal('POST')); var_dump($form->validate()); Expected result: ---------------- bool(false) Actual result: -------------- Warning: strlen() expects parameter 1 to be string, array given bool(true)

Comments

 [2015-11-20 21:15 UTC] stav (Bastien Blanchard)