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

Skip to content

[2.7] Expanded Entity Form Element with negative id values #15273

Closed
@Waigie

Description

@Waigie

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

ID Name
-1 Foo
1 Bar
2 Baz

Code

class ExampleForm extends Form
{
    public function buildForm(FormBuilderInterface $builder, array $options) {
        $builder->add(
            'element',
            'entity',
            array(
                'class' => 'AppBundle:ExampleEntity',
                'label' => 'Expanded Entity',
                'expanded' => true,
                'multiple' => true,
            )
        );
    }
}

Creating this form with the Symfony Form Builder will generate the following Error:

The name "-1" contains illegal characters. Names should start with a letter, digit or underscore and only contain letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":").

Prior to Symfony 2.7.0 everything works fine, including 2.6.10.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions