#6432: form helper gets confused by some validation rules ---------------------------+------------------------------------------------ Reporter: q7joey | Type: Bug Status: new | Priority: Medium Milestone: 1.2.x.x | Component: Helpers Version: 1.2 Final | Severity: Normal Keywords: | Php_version: PHP 5 Cake_version: 1.2.3.8166 | ---------------------------+------------------------------------------------ this appears to be related to #3869.
any field that has a validation rule and is not marked as required=>false will normally get the required class added to the div. but if the rule is one that is configured via an array (like array(postal,null,us)) and the rule=> index happens to be first, then the required tag is not presented. this is caused because Set::countDim is used and it only looks at the first element by default to determine the array depth and when the form helper sees a depth greater than one, it assumes multiple rules and then the logic breaks. if put a simple entry before the rule=> index, then the form helper works. for example: {{{ #!php // does not add 'required' class $validate = array( 'zip' => array( 'rule' => array('postal',null,'us'), 'message' => 'Invalid ZIP', ), ); // does add 'required' class $validate = array( 'zip' => array( 'message' => 'Invalid ZIP', 'rule' => array('postal',null,'us'), ), ); }}} the code in question is around line 142 in cake/libs/view/helpers/form.php. i'm not sure of the best fix for this, maybe a check to see if 'rule' is set in the array? that seems to be the logic being used in cake/lib/model/model.php. -- Ticket URL: <https://trac.cakephp.org/ticket/6432> CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/> Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "tickets cakephp" group. To post to this group, send email to tickets-cakephp@googlegroups.com To unsubscribe from this group, send email to tickets-cakephp+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/tickets-cakephp?hl=en -~----------~----~----~----~------~----~------~--~---