Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form] Use empty_data for form default values. #16530

Copy link
Copy link
Closed
@lyrixx

Description

@lyrixx
Issue body actions

Hello.

I did not used the form component for a while, So I may be wrong (but see this doc)

First, I pushed to code to ease understatement: lyrixx/symfony-standard@d203604

Basically, I create a form without data but with a data_class.
My "Entity" class have default values, So I expected to see the default values as the form default values. But instead, my form is empty:

screenshot8

If I inspect the HTML, I can see this (manually indented):

<form name="foo" method="post" action="">
    <div id="foo">
        <div>
            <label for="foo_enabled" class="required">Enabled</label>
            <input type="checkbox" id="foo_enabled" name="foo[enabled]" required="required" value="1" />
        </div>
        <div>
            <label for="foo_name" class="required">Name</label>
            <input type="text" id="foo_name" name="foo[name]" required="required" />
        </div>
        <input type="hidden" id="foo__token" name="foo[_token]" value="_Y4JKjDkfmIaaiAmtoOWDz6QQDpHLy0La2dtbzue2Q4" />
    </div>
</form>

First you can note the value="1" in the checkbox input.
Then, there is no value for the name.

I tried few symfony version from v2.6.3 to 2.7.6, it's always the same things.

So I tried to use empty_data => same result.

So, again, I tried to lower symfony requirement => same result for symfony 2.6.3

So I finally tried symfony 2.3 => and again, same result.


So, It could be nice to use the empty_data option to populate the form

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.