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

Skip to content

interger and number do not return correct empty_data #12499

Closed
@hpatoio

Description

@hpatoio

Given this simple form.

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name')
            ->add('votes', 'text', array('empty_data' => 0))
        ;
    }

If I leave the field votes empty when I submit the form $form['votes']->getData() gives me 0

If I change the field type to number or integer

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name')
            ->add('votes', 'number', array('empty_data' => 0))
        ;
    }

$form['votes']->getData() gives me null

Is this the correct behavior ? Is this related to #5906 ?

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