[Form] DRYed ChoiceType
This commit is contained in:
parent
0753cee11a
commit
8321593c85
@ -190,21 +190,23 @@ class ChoiceType extends AbstractType
|
|||||||
if (is_array($choiceView)) {
|
if (is_array($choiceView)) {
|
||||||
// Flatten groups
|
// Flatten groups
|
||||||
$this->addSubFields($builder, $choiceView, $options);
|
$this->addSubFields($builder, $choiceView, $options);
|
||||||
} elseif ($options['multiple']) {
|
} else {
|
||||||
$builder->add((string) $i, 'checkbox', array(
|
$choiceOpts = array(
|
||||||
'value' => $choiceView->getValue(),
|
'value' => $choiceView->getValue(),
|
||||||
'label' => $choiceView->getLabel(),
|
'label' => $choiceView->getLabel(),
|
||||||
|
'translation_domain' => $options['translation_domain'],
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($options['multiple']) {
|
||||||
|
$choiceType = 'checkbox';
|
||||||
// The user can check 0 or more checkboxes. If required
|
// The user can check 0 or more checkboxes. If required
|
||||||
// is true, he is required to check all of them.
|
// is true, he is required to check all of them.
|
||||||
'required' => false,
|
$choiceOpts['required'] = false;
|
||||||
'translation_domain' => $options['translation_domain'],
|
} else {
|
||||||
));
|
$choiceType = 'radio';
|
||||||
} else {
|
}
|
||||||
$builder->add((string) $i, 'radio', array(
|
|
||||||
'value' => $choiceView->getValue(),
|
$builder->add((string) $i, $choiceType, $choiceOpts);
|
||||||
'label' => $choiceView->getLabel(),
|
|
||||||
'translation_domain' => $options['translation_domain'],
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user