Skip to content

Conversation

@ureimers
Copy link
Contributor

Added documentation for how to correctly pre-fill a form using the form's data option.
The "old" and also wrong way of doing it broke with Symfony 2.3.7 (with #9388 to be precise) and this short documentation should help others to fix the problem and do it right.

UPGRADE-2.3.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Although

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although was already used at the beginning paragraph of the file so I wanted to spice up the wording. Maybe "While" would be o.k. too?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes

The fact that not setting the `data` option doesn't lock the form can be taken out of the description which states that *if* the `data` option is set the data will be locked automatically (so the opposite must be happening if it isn't).
UPGRADE-2.3.md Outdated
Copy link
Member

Choose a reason for hiding this comment

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

The other way is to omit the data option entirely when you don't have a default data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had that in there in the first place (ureimers@1c74898) but Luis mentioned that it would be better to be explicit and I agreed so I removed that alternative. I honestly starting to don't know which way is the best here and if I should show them both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What users want to accomplish is set a value that is always used if there is no data bound and never used if there is.
In other words: They want to implement a default_value option.
Before 2.3.7 they where able to accomplish that with the above mentioned code under Before:.
So to be able to do that >=2.3.7 they need to change their code like I mentioned in After:.
I think as a guideline to how to accomplish something in 2.3 you where able to do prior 2.3 this should suffice.

Copy link
Member

Choose a reason for hiding this comment

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

IMO, omitting the data option is a better implementation than passing the data option and then modifying the builder to tell it to ignore it

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @stof.

@webmozart
Copy link
Contributor

Sent PR ureimers#1 to update the wording and before/after example.

[Form] Fixed wording in the UPGRADE file
fabpot added a commit that referenced this pull request Jan 6, 2014
This PR was submitted for the 2.3-dev branch but it was merged into the 2.3 branch instead (closes #9804).

Discussion
----------

[Form] Update UPGRADE-2.3.md to account for #9388

Added documentation for how to correctly pre-fill a form using the form's `data` option.
The "old" and also wrong way of doing it broke with Symfony 2.3.7 (with #9388 to be precise) and this short documentation should help others to fix the problem and do it right.

Commits
-------

5e06535 [Form] Update UPGRADE-2.3.md to account for #9388
@fabpot fabpot closed this Jan 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants