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

[WIP] [2.7+] explicit differences between 'data' & 'empty_data' options in FormType#6265

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

Closed

Conversation

@HeahDude
Copy link
Contributor

It seems to be some confusion between two optionsdata and empty_data` in regard of these two old symfony issues I read yesterday (symfony/symfony#14579,symfony/symfony#16530).

Probably because of their name and the fact that they both are some kind of "placeholder" in different step of the form cycle.

@jakzal advise me to open a PR here for that matter.

IMO both of their descriptions are already pretty clear.

You can see in this PR an attempt to explicit and focus on the context in which they are requested.

Any idea or suggestions are welcome.

The default values for form fields are taken directly from the underlying
data structure(e.g. an entity or an array). The ``data`` option overrides
this default value.
data structurematching the field name with a property of an object or a
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I tried to centralize structure references in the note.

This option determines what value the field will return when the submitted
value is empty.
value is empty. It does not set an initial value if none is provided when
the form is rendered in a view (see ``data`` or ``placeholder`` options).
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

It would be nice to link the options

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Please can some one tell me how can I do it?

@HeahDude
Copy link
ContributorAuthor

Updated. closes#6340.

@HeahDude
Copy link
ContributorAuthor

Any reviews here? There are many confusions about this.

data structure(e.g. an entity or an array). The ``data`` option overrides
this default value.
data structurematching the field's name with a property of an object or a
key of an array. The ``data`` option overridesthis default value.
Copy link
Member

Choose a reason for hiding this comment

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

You should make it clearer than overriding the default value like this will cause issues if you are using the form to edit an object rather than to create it, as the form value will still be filled fromdata even if the underlying data structure also has a value for it

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thank you for this heads-up!

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@stof done in the sentence below

@HeahDudeHeahDudeforce-pushed theform-empty_data-option branch frome3894be to133a77cCompareMay 21, 2016 11:25
@HeahDude
Copy link
ContributorAuthor

HeahDude commentedMay 21, 2016
edited
Loading

Ok there is quite some work here before it's finished.

I propose to override theempty_data option globally for:

  • choice types (used for choice, locale, country, currency, timezone with some expanded examples info in choice type about multiple and an update withchoice_name option in 2.7+),
  • time types (birthday, date, date time, time), note that actually the option is missing in these types and there is[3.0] [Form] DateType ignores "empty_data" option symfony#4715,
  • one specific about entity type (about string ids),
  • suggestions ?

with dedicated example. It would be easier with a second marker like it's currently done withDEFAULT_PLACEHOLDER.

What do you think?

@xabbuh
Copy link
Member

@HeahDude sounds like a good plan to me

@HeahDude
Copy link
ContributorAuthor

Refsymfony/symfony#19165

@HeahDudeHeahDude changed the title[WIP] [2.3+] explicit differences between 'data' & 'empty_data' options in FormType[WIP] [2.7+] explicit differences between 'data' & 'empty_data' options in FormTypeJul 2, 2016
@xabbuh
Copy link
Member

@HeahDude Do you think you may find some time to finish this one? :)

@HeahDude
Copy link
ContributorAuthor

It's hard to find some time these days, but sure I will :) In the meanwhile if someone wants to take over this PR, let it be!

@wouterj
Copy link
Member

Closing in favor of#7802

xabbuh added a commit that referenced this pull requestMay 4, 2017
…s more visisble (HeahDude, wouterj, javiereguiluz)This PR was merged into the 2.7 branch.Discussion----------[Form] Make difference between data and empty_data options more visisbleFinishes#6265Fixes#7299,#7596Commits-------64e3984 Fixed a minor typodf9b878 Fixed a minor typof375489 Better explain empty_data valuesd552ea3 Readd mixed type for empty_data, it can be string, array or object188f0ab Tried to write the important points more explicitly5f3813d Updated the example add added a caution4fd2d96 Addressed@stof's comment242941a improved accuracy67c93b6 fix typo87b3542 explicit differences between 'data' & 'empty_data' in FormType
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

4 participants

@HeahDude@xabbuh@wouterj@stof

[8]ページ先頭

©2009-2025 Movatter.jp