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

Request #16974 Possibility to bypass "intrinsic validation" for HTML_QuickForm2_Element_Select
Submitted: 2010-01-06 19:38 UTC
From: thedotedge Assigned:
Status: Duplicate Package: HTML_QuickForm2 (version 0.3.0)
PHP Version: 5.3.0 OS: Not relevant
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 35 + 42 = ?

 
 [2010-01-06 19:38 UTC] thedotedge (Oleg Oleg)
Description: ------------ It's sometimes needed to pass values from dynamically populated controls, one example would be to have city select box repopulated whenever you change country select box. The problem is that you wouldn't get this value when you do $form->getValue(), because it's not among valid select options from Quickform perspective. It would be nice to bypass this check (Zend_Form has this feature), like: public function getValue() { # PATCHED to be able to extract values from dynamic selects, i.e. addElement('select', 'city_id', null, array('options' => array(), 'bypass_intrinsic_validation' => true)); if ((0 == count($this->optionContainer) || 0 == count($this->values) || 0 == count($this->possibleValues)) && !$this->data['bypass_intrinsic_validation'] || !empty($this->attributes['disabled'])) { return null; } $values = array(); foreach ($this->values as $value) { # PATCHED to be able to extract values from dynamic selects, i.e. addElement('select', 'city_id', null, array('options' => array(), 'bypass_intrinsic_validation' => true)); if (!empty($this->possibleValues[$value]) || $this->data['bypass_intrinsic_validation']) { $values[] = $value; } } if (0 == count($values)) { return null; } elseif (!empty($this->attributes['multiple'])) { return $values; } elseif (1 == count($values)) { return $values[0]; } else { // The <select> is not multiple, but several options are to be // selected. At least IE and Mozilla select the last selected // option in this case, we should do the same foreach ($this->optionContainer->getRecursiveIterator() as $child) { if (is_array($child) && in_array($child['attr']['value'], $values)) { $lastValue = $child['attr']['value']; } } return $lastValue; } }

Comments

 [2010-01-06 21:41 UTC] thedotedge (Oleg Oleg)
-Summary: Possibility to bypass +Summary: Possibility to bypass "intrinsic validation" for HTML_QuickForm2_Element_Select
 [2010-01-11 22:43 UTC] avb (Alexey Borzov)
-Status: Open +Status: Duplicate
Duplicate of bug #13088