Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
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
Prev Previous commit
Next Next commit
fix CS
  • Loading branch information
ruian committed Jan 7, 2014
commit 5a415555bdf5584e59ca09ef1f34d5a10d5d24f8
11 changes: 5 additions & 6 deletions src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\Exception\LogicException;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
use Symfony\Component\Form\Extension\Core\EventListener\FixRadioInputListener;
use Symfony\Component\Form\Extension\Core\EventListener\FixCheckboxInputListener;
Expand All @@ -26,9 +27,8 @@
use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToBooleanArrayTransformer;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class ChoiceType extends AbstractType
{
Expand Down Expand Up @@ -157,9 +157,8 @@ public function buildView(FormView $view, FormInterface $form, array $options)
$view->vars['full_name'] = $view->vars['full_name'].'[]';
}

$choicesAttributes = $options['choices_attributes'];
$choicesPrototypes = $options['choices_prototypes'];
if (count($choicesAttributes) || count($choicesPrototypes)) {
if (!empty($options['choices_attributes']) || !empty($options['choices_prototypes'])) {
$choicesAttributes = $options['choices_attributes'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of this variable? You are not manipulating that array, so IMO the is no real point of adding it and not working directly on $options['choices_attributes'].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

humm you must be right.

foreach ($view->vars['choices'] as $key => $choiceView) {
if (array_key_exists($key, $choicesAttributes)) {
$choiceView->attr = $choicesAttributes[$key];
Expand Down Expand Up @@ -242,7 +241,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
};

$choicesClosureNormalizer = function (Options $options, $values) {
if ($values instanceof \Closure && false === is_array($values = $values($options['choice_list']))) {
if ($values instanceof \Closure && !is_array($values = $values($options['choice_list']))) {
throw new UnexpectedTypeException($values, 'array');
}

Expand Down