-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.7] Expanded Entity Form Element with negative id values #15273
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
Comments
Reproduced here. |
re #14050 @Waigie until this is fixed, you can implement a workaround and define a $builder->add(
'element',
'entity',
[
'class' => ExampleEntity::class,
'label' => 'Expanded Entity',
'expanded' => true,
'multiple' => true,
'choice_name' => function ($choice) {
return str_replace('-', '_', $choice);
}
]
); |
fabpot
added a commit
that referenced
this issue
Jul 15, 2015
This PR was merged into the 2.7 branch. Discussion ---------- [Form] Fix a BC break in the entity | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15273 | License | MIT | Doc PR | - @webmozart this brings back the old behaviour. Attached test case passes on 2.3 with no code modifications. Code [here](https://github.com/symfony/symfony/blob/73bbaa6cc7d706b0e945107657fbd240efec0c97/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php#L199-L206) promises any integer number can be handled with `createChoiceName()`: ```php // If the object has a single-column, numeric ID, use that ID as // field name. We can only use numeric IDs as names, as we cannot // guarantee that a non-numeric ID contains a valid form name if ($idReader->isIntId()) { return array(__CLASS__, 'createChoiceName'); } // Otherwise, an incrementing integer is used as name automatically ``` While `createChoiceName()` can only handle natural numbers. Commits ------- 03642b8 [Form] Fix a BC break in the entity
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since 2.7 using expanded Entity Form Elements, which allow multiple selections (checkboxes) with data having negativ IDs is not possible anymore, because the new naming conventions prohibit names starting with a '-'
Example
Database Table
Code
Creating this form with the Symfony Form Builder will generate the following Error:
Prior to Symfony 2.7.0 everything works fine, including 2.6.10.
The text was updated successfully, but these errors were encountered: