-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add a 2nd argument to create() #9413
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
Maybe I'm wrong but I tried the exemple with my case and the test failed because IMO if we don't pass an object to second argument, $form->getData() will return an array and this->assertEquals() can't compare an object with an array. What do you think :-)
Let's ask for a review to our Forms expert @vudaltsov Thanks! |
To be more precise, the type of the returned data depends on whether or not the |
form/unit_testing.rst
Outdated
|
||
|
||
$objectToCompare = new TestObject(); | ||
//$objectToCompare will retrieve data from the form submission pass it at second argument |
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.
missing space after //
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.
and 1 space before //
, 1 space before $objectToCompare
(the indents are incorrect).
form/unit_testing.rst
Outdated
$object = new TestObject(); | ||
// ...populate $object properties with the data stored in $formData | ||
|
||
// submit the data to the form directly | ||
$form->submit($formData); | ||
|
||
|
||
//Will fill data in $objectToCompare |
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.
same here
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 would actually just remove this comment
form/unit_testing.rst
Outdated
|
||
|
||
//Will fill data in $objectToCompare | ||
$objectToCompare = $form->getData(); |
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 would not introduce this variable here. There is no need for 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 understand but IMO it's strange to declare a variable, pass it as an argument and never use it after.
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.
But now we are doing exactly that because we are overwriting the previously declared variable.
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.
@xabbuh do we need to change anything in the merged PR? If yes, could you please create a quick issue (or PR) to not forget about it? Thanks a lot!
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.
see #9431
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 like this PR, it's a common practice to use object itself, not $form->getData()
.
But CS should be fixed.
form/unit_testing.rst
Outdated
|
||
|
||
$objectToCompare = new TestObject(); | ||
//$objectToCompare will retrieve data from the form submission pass it at second argument |
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.
and 1 space before //
, 1 space before $objectToCompare
(the indents are incorrect).
form/unit_testing.rst
Outdated
$object = new TestObject(); | ||
// ...populate $object properties with the data stored in $formData | ||
|
||
// submit the data to the form directly | ||
$form->submit($formData); | ||
|
||
|
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.
remove spaces on an empty line
Thanks for all feedbacks, I'll work on quickly, |
I updated to correct CS
👍 Looks great, thanks! status: reviewed |
Thanks for this nice contribution! Help with form docs is always much appreciated! We merged this on 2.7 branch. |
This PR was submitted for the 4.0 branch but it was squashed and merged into the 2.7 branch instead (closes #9413). Discussion ---------- Add a 2nd argument to create() Maybe I'm wrong but I tried the exemple with my case and the test failed because IMO if we don't pass an object to second argument, $form->getData() will return an array and this->assertEquals() can't compare an object with an array. What do you think :-) Commits ------- ecef1fc Add a 2nd argument to create()
It’s always a pleasure to help us even I’m still waiting for the « Documentation’s Badge contributor » 😜 |
* 2.7: [symfony#9413] some minor tweaks Ask users to create two commits for reproducers
* 2.8: [symfony#9413] some minor tweaks Ask users to create two commits for reproducers
* 3.4: Adding a documentation page about Bootstrap 4 form theme [symfony#9413] some minor tweaks Ask users to create two commits for reproducers Improved variable naming
Maybe I'm wrong but I tried the exemple with my case and the test failed because IMO if we don't pass an object to second argument, $form->getData() will return an array and this->assertEquals() can't compare an object with an array.
What do you think :-)