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

Request #16974 Possibility to bypass "intrinsic validation" for HTML_QuickForm2_Element_Select
Submitted: 2010-01-06 14:38 UTC Modified: 2010-01-11 17:43 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  


 [2010-01-06 14: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 16:41 UTC] thedotedge (Oleg Oleg)
-Summary: Possibility to bypass +Summary: Possibility to bypass "intrinsic validation" for HTML_QuickForm2_Element_Select
 [2010-01-11 17:43 UTC] avb (Alexey Borzov)
-Status: Open +Status: Duplicate
Duplicate of bug #13088