Skip to content

[Forms] Fixed TextType empty_data value explanation #10743

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

Merged
merged 1 commit into from
Dec 8, 2018

Conversation

vudaltsov
Copy link
Contributor

@vudaltsov vudaltsov commented Dec 8, 2018

#SymfonyConHackDay

See symfony/symfony#18357 that introduced a way to use an empty string in models, so setter does not have to be nullable. Usage example: https://github.com/EnMarche/en-marche.fr/blob/master/src/Form/TypeExtension/TextTypeExtension.php#L28

Thanx to @HeahDude for helping me with this PR.

The default value is ``''`` (the empty string).
From an HTTP perspective, submitted data is always a string or an array of strings.
So by default, the form will treat any empty string as null. If you prefer to get
an empty string, explicitly set the ``empty_data`` option to an empty string.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@symfony/team-symfony-docs should we care about adding a note to say this possible since 3.2 only?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed because we merge in 3.4, so the minimum Symfony version already has that.

@HeahDude HeahDude added the Form label Dec 8, 2018
@HeahDude HeahDude added this to the 3.4 milestone Dec 8, 2018
@vudaltsov vudaltsov changed the title Fixed TextType empty_data value explanation [Forms] Fixed TextType empty_data value explanation Dec 8, 2018
@stof
Copy link
Member

stof commented Dec 8, 2018

#SymfonyConHackday2018

@javiereguiluz
Copy link
Member

Much better explained. Thanks a lot Valentin!

@javiereguiluz javiereguiluz merged commit 5cfff92 into symfony:3.4 Dec 8, 2018
javiereguiluz added a commit that referenced this pull request Dec 8, 2018
…altsov)

This PR was merged into the 3.4 branch.

Discussion
----------

[Forms] Fixed TextType empty_data value explanation

#SymfonyConHackDay

See symfony/symfony#18357 that introduced a way to use an empty string in models, so setter does not have to be nullable. Usage example: https://github.com/EnMarche/en-marche.fr/blob/master/src/Form/TypeExtension/TextTypeExtension.php#L28

Thanx to @HeahDude for helping me with this PR.

Commits
-------

5cfff92 Fix TextType empty_data value explanation
@vudaltsov vudaltsov deleted the text-empty-data-string branch December 8, 2018 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants