8000 [2.2][Form] Fixed expanded choice field to be marked invalid when unknown choices are submitted by webmozart · Pull Request #8980 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[2.2][Form] Fixed expanded choice field to be marked invalid when unknown choices are submitted #8980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 10, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[Form] Removed usage of the ChoiceList::getIndicesFor*() methods wher…
…e they don't offer any performance benefit
  • Loading branch information
webmozart committed Sep 10, 2013
commit 53f292adcc54ee97479c26aca638da713f3013a0
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public function transform($choice)
throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e);
}

$index = current($this->choiceList->getIndicesForChoices(array($choice)));
$valueMap = array_flip($this->choiceList->getValuesForChoices(array($choice)));

foreach ($values as $i => $value) {
$values[$i] = $i === $index;
$values[$i] = isset($valueMap[$value]);
}

return $values;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public function transform($array)
throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e);
}

$indexMap = array_flip($this->choiceList->getIndicesForChoices($array));
$valueMap = array_flip($this->choiceList->getValuesForChoices($array));

foreach ($values as $i => $value) {
$values[$i] = isset($indexMap[$i]);
$values[$i] = isset($valueMap[$value]);
}

return $values;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)

// Check if the choices already contain the empty value
// Only add the empty value option if this is not the case
if (0 === count($options['choice_list']->getIndicesForValues(array('')))) {
if (0 === count($options['choice_list']->getChoicesForValues(array('')))) {
$view->vars['empty_value'] = $options['empty_value'];
}

Expand Down
0