-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Update UPGRADE-2.3.md to account for #9388 #9804
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
Conversation
Although the output was fine the .md file wasn't.
to the data of the object bound to the form (if one was bound). | ||
This was used in some projects to pre-set a form field with optional | ||
initial data as long as there wasn't already data set through a bound object. | ||
Altough this feature is intended, setting the `data` option for a form |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
$builder->add('field', 'text', array( | ||
'data' => $options['default_data'] ?: null, | ||
)); | ||
$builder->get('field')->setDataLocked(false); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @stof.
Sent PR ureimers#1 to update the wording and before/after example. |
[Form] Fixed wording in the UPGRADE file
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
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.