-
-
Notifications
You must be signed in to change notification settings - Fork 334
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
[LiveComponent] Add Documentation for testing with LiveCollectionType #2517
base: 2.x
Are you sure you want to change the base?
[LiveComponent] Add Documentation for testing with LiveCollectionType #2517
Conversation
src/LiveComponent/doc/index.rst
Outdated
$component->call('addCollectionItem', ['name' => 'children']); | ||
//... can be called as many times as you need entries in your 'children' field | ||
|
||
// and then submit the 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.
// and then submit the form | |
// ... then submit the form by providing data for all the fields in the ChildFormType: |
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.
Looking at the next review, I would add at the end of your updated comment for each added entry
or something of sort
src/LiveComponent/doc/index.rst
Outdated
} | ||
} | ||
|
||
The test of the submission of such form would be with the TestHelper:: |
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 test of the submission of such form would be with the TestHelper:: | |
Use the addCollectionItem method from the LiveCollectionTrait to dynamically add entries to the children field of the 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.
Indeed more descriptive and I would add at the end of your updated comment : "before submitting 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.
Some minor details to fix (if you agree), very nice addition, thank you!
Thanks for the review which makes full sense. I'll look at it today. |
- better english ;-) - clearer description of steps - better use of RST (double backticks instead of single ;-))
Updates made based on the review and updated proposals |
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.
Thank you @yalit !
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.
may I propose to use another field name, to not overlap with the
$component->call('addCollectionItem', ['name' => 'children']);
wdyt?
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder | ||
->add('name', TextType::class) |
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.
->add('name', TextType::class) | |
->add('firstName', TextType::class) |
// ... then submit the form by providing data for all the fields in the ChildFormType for each added entry: | ||
$component->submitForm([ 'live_collection_form' => [ | ||
'children' => [ | ||
['name' => 'childName1', 'age' => 10], |
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.
['name' => 'childName1', 'age' => 10], | |
['firstName' => 'childName1', 'age' => 10], | |
['firstName' => 'childName2', 'age' => 15], |
@94noni, for me it's indeed better, nice update. As it doesn't change the information of the doc but improves it (in my opinion), I would assume it's ok for @smnandre (I can do the update today). As already approved, can you confirm from your side? |
As mentioned in the #2512, I had trouble testing the submission of a form containing a LiveCollectionType field due to lack of proper guidance in the documentation. Hence this pull request to propose an addendum in the documentation linked to that capability