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

Skip to content

[Form] Broken ModelType (Propel) in 2.8 release #16792

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

Closed
piogrek opened this issue Dec 1, 2015 · 1 comment
Closed

[Form] Broken ModelType (Propel) in 2.8 release #16792

piogrek opened this issue Dec 1, 2015 · 1 comment
Labels

Comments

@piogrek
Copy link

piogrek commented Dec 1, 2015

After merge from 2.7, forms using ModelType stopped working.

The 'choice' option can be null, array or Traversable, but normalizeLegacyChoices function in ChoiceType forces $choices to be an array. In ModelType choices are fetched from the query, so we need 'choices' to be null. In our case temporary workaround is to add 'choices_as_values' => true

public static function normalizeLegacyChoices(array &$choices, $choiceLabels, &$nextKey = 0)

The error I get is:

Catchable Fatal Error: Argument 1 passed to Symfony\Component\Form\Extension\Core\Type\ChoiceType::normalizeLegacyChoices() must be of the type array, null given, called in /private/var/www/posse/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php on line 266 and defined

my form field definition:

use Symfony\Bridge\Propel1\Form\Type\ModelType;
...
$builder
    ->add(
        'TakeByWebType',
        ModelType::class,
        [
            'label'      => 'Type',
            'required'   => true,
            'class'      => '\Posse\SurveyBundle\Model\Type\TakeByWebType',
            'query'      => $query,
            'property'   => 'description',
        ]
    );
@nicolas-grekas
Copy link
Member

Can you please try #16796?

@xabbuh xabbuh added the Form label Dec 2, 2015
stof added a commit that referenced this issue Dec 5, 2015
This PR was merged into the 2.8 branch.

Discussion
----------

[Form] Fix choices defined as Traversable

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #16792
| License       | MIT
| Doc PR        | -

Commits
-------

021d93a [Form] Fix choices defined as Traversable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants