8000 [3.0] [Form] Setting "empty_data" to "" still results in NULL · Issue #5906 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[3.0] [Form] Setting "empty_data" to "" still results in NULL #5906
Closed
@webmozart

Description

@webmozart

When setting the "empty_data" option of a text field to "", the submitted value is still converted to null.

$form = $formFactory->createBuilder()
    ->add('task', 'text', array(
        'required' => false,
        'empty_data' => '',
    ))
    ->getForm();

if (isset($_POST[$form->getName()])) {
    $form->bind($_POST[$form->getName()]);

    var_dump($form->getData());
    die;
}

Actual result:

array (size=1)
  'task' => null

Expected result:

array (size=1)
  'task' => ""

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0