added validation support for optgroups #2331

Merged
merged 2 commits into from Sep 13, 2012

Conversation

Projects
None yet
3 participants
@jamescarr
Contributor

jamescarr commented Sep 10, 2012

Commits speak for themselves. Changed getOptionsValues() to extract nested values from option groups. This allows for proper validation of Selects that have optgroups in them.

@cgmartin

This comment has been minimized.

Show comment
Hide comment
@cgmartin

cgmartin Sep 10, 2012

Contributor

Looks good 👍

Contributor

cgmartin commented Sep 10, 2012

Looks good 👍

}
return $values;
}
+
+ private function getOptionValue($key, $optionSpec)

This comment has been minimized.

@weierophinney

weierophinney Sep 13, 2012

Member

protected visibility, please.

@weierophinney

weierophinney Sep 13, 2012

Member

protected visibility, please.

@@ -175,9 +175,19 @@ protected function getValueOptionsValues()
$values = array();
$options = $this->getValueOptions();
foreach ($options as $key => $optionSpec) {
- $value = (is_array($optionSpec)) ? $optionSpec['value'] : $key;
- $values[] = $value;
+ if(is_array($optionSpec) && array_key_exists('options', $optionSpec)){

This comment has been minimized.

@weierophinney

weierophinney Sep 13, 2012

Member

Add whitespace between if and opening paren, and between closing paren and opening brace.

@weierophinney

weierophinney Sep 13, 2012

Member

Add whitespace between if and opening paren, and between closing paren and opening brace.

+ foreach ($optionSpec['options'] as $nestedKey => $nestedOptionSpec) {
+ $values[] = $this->getOptionValue($nestedKey, $nestedOptionSpec);
+ }
+ }else{

This comment has been minimized.

@weierophinney

weierophinney Sep 13, 2012

Member

Add whitespace around the else keyword, please.

@weierophinney

weierophinney Sep 13, 2012

Member

Add whitespace around the else keyword, please.

weierophinney added a commit that referenced this pull request Sep 13, 2012

[#2331] CS fixes
- whitespace
- loop branching
- private -> protected
@weierophinney

This comment has been minimized.

Show comment
Hide comment
@weierophinney

weierophinney Sep 13, 2012

Member

Incorporated feedback, and merged to release and master branches.

Member

weierophinney commented Sep 13, 2012

Incorporated feedback, and merged to release and master branches.

@weierophinney weierophinney merged commit 3cb169c into zendframework:master Sep 13, 2012

1 check passed

default The Travis build passed
Details

@ghost ghost assigned weierophinney Sep 13, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment