Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Form] String is the preferred value type for TextType#15404

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
peter-gribanov wants to merge1 commit intosymfony:6.1
base:6.1
Choose a base branch
Loading
frompeter-gribanov:form_text_type_stringable_upgrade

Conversation

peter-gribanov
Copy link

@peter-gribanovpeter-gribanov commentedJun 3, 2021
edited
Loading

Reasonsymfony/symfony#41514 andsymfony/symfony#41516

Thetext_empty_data_description.rst.inc file is a copy ofempty_data_description.rst.inc:

This option determines what value the field will *return* when the submittedvalue is empty (or missing). It does not set an initial value if none isprovided when the form is rendered in a view.This means it helps you handling form submission with blank fields. Forexample, if you want the ``name`` field to be explicitly set to ``John Doe``when no value is selected, you can do it like this::    $builder->add('name', null, [        'required'   => false,        'empty_data' => 'John Doe',    ]);This will still render an empty text box, but upon submission the ``John Doe``value will be set. Use the ``data`` or ``placeholder`` options to show thisinitial value in the rendered form.If a form is compound, you can set ``empty_data`` as an array, object orclosure. See the :doc:`/form/use_empty_data` article for more details aboutthese options... note::    If you want to set the ``empty_data`` option for your entire form class,    see the :doc:`/form/use_empty_data` article.--.. caution::--    :doc:`Form data transformers </form/data_transformers>` will still be-    applied to the ``empty_data`` value. This means that an empty string will-    be cast to ``null``. Use a custom data transformer if you explicitly want-    to return the empty string.

@javiereguiluz
Copy link
Member

@xabbuh do you have any comments about this proposal? Thanks!

]);

This will still render an empty text box, but upon submission the ``John Doe``
value will be set. Use the ``data`` or ``placeholder`` options to show this
Copy link
Member

@ycerutoycerutoAug 8, 2022
edited
Loading

Choose a reason for hiding this comment

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

I wouldn't encourage the use of the innerdata option for the default value. Cause that when it's a mapped field thedata value set here will replace the bound value that comes from the underlying subject, thus it doesn't behave as a default value. There is already a warning note about it in
https://symfony.com/doc/current/reference/forms/types/text.html#data

We should use the underlying subject to the root form to set default values or aPRE_SET_DATA event listener instead.

Copy link
Member

Choose a reason for hiding this comment

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

and theplaceholder option is only for display but it also doesn't actually set an initial value for this field

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I see, maybe that's something to fix from 4.4 (in another PR).

Copy link
Member

@ycerutoyceruto left a comment

Choose a reason for hiding this comment

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

LGTM

]);

This will still render an empty text box, but upon submission the ``John Doe``
value will be set. Use the ``data`` or ``placeholder`` options to show this
Copy link
Member

Choose a reason for hiding this comment

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

I see, maybe that's something to fix from 4.4 (in another PR).

@wouterjwouterj added the Waiting Code MergeDocs for features pending to be merged labelSep 11, 2022
@carsonbotcarsonbot added this to thenext milestoneSep 11, 2022
@wouterj
Copy link
Member

As far as I can see, this PR requires the 2 PRs submitted to the code repository to be merged first. I've added the "waiting code merge" label to clarify it.

If this is wrong, please let us know :)

@peter-gribanovpeter-gribanov changed the base branch from5.4 to6.1September 27, 2022 11:35
@peter-gribanovpeter-gribanovforce-pushed theform_text_type_stringable_upgrade branch fromcb28cef tob6f42eeCompareSeptember 27, 2022 11:45
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ycerutoycerutoyceruto approved these changes

@xabbuhxabbuhAwaiting requested review from xabbuhxabbuh is a code owner

Assignees
No one assigned
Labels
FormStatus: ReviewedWaiting Code MergeDocs for features pending to be merged
Projects
None yet
Milestone
next
Development

Successfully merging this pull request may close these issues.

5 participants
@peter-gribanov@javiereguiluz@wouterj@yceruto@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp