Skip to content

[LiveComponent] Update doc on how to use submitForm #2510

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

Merged

Conversation

yalit
Copy link
Contributor

@yalit yalit commented Jan 19, 2025

Q A
Bug fix? no
New feature? no
Issues Fix #2509
License MIT

As described in the issue, I struggled a bit with the usage of the submitForm helper for testing a LiveComponent due to the name of the form used not being correct see #2509.

I propose a small update to the documentation to make it more clear how the formName should be used into the call of submitForm

@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Jan 19, 2025
Comment on lines 3736 to 3737
// 'form' is the name of the form you're submitting (here FormType).
// e.a : form submitted is EntityCreationType the name of your form would be 'entity_creation' and should replace 'form' in the below submitForm call
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest to remove the text and use another word than "form" in the exemple..

Something like "create_comment" or "my_form" .

wdyt ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed, I didn't want to update the "core" of the documentation but if it's a possibility, we could indeed do something like:

// Submit form data ('my_form' for your MyFormType form)
$testComponent
    ->submitForm(['my_form' => ['input' => 'value']], 'save');

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 pushed that modification

@smnandre smnandre added docs Improvements or additions to documentation LiveComponent DX Status: Reviewing Review is ongoing, refining with author and removed Status: Needs Review Needs to be reviewed labels Jan 19, 2025
@smnandre smnandre changed the title doc : update comment on submitForm in the LiveComponent testing doc [LiveComponent] Update doc on how to use submitForm Jan 19, 2025
Comment on lines 3736 to 3737
// 'form' is the name of the form you're submitting (here FormType).
// e.a : form submitted is EntityCreationType the name of your form would be 'entity_creation' and should replace 'form' in the below submitForm call
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// 'form' is the name of the form you're submitting (here FormType).
// e.a : form submitted is EntityCreationType the name of your form would be 'entity_creation' and should replace 'form' in the below submitForm call
// 'form' is the name of the form you're submitting (here FormType).
// e.a : form submitted is EntityCreationType the name of your form would be 'entity_creation' and should replace 'form' in the below submitForm call

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 don't know why i was doing that but when looking at the actual render it was properly aligned... Anyhow, a new commit has been made with a simplification of the comments

@carsonbot carsonbot added the Status: Reviewed Has been reviewed by a maintainer label Jan 19, 2025
@Kocal Kocal removed the Status: Reviewing Review is ongoing, refining with author label Jan 20, 2025
@Kocal Kocal force-pushed the doc/update_doc_for_testing_live_component_submit_form branch from 5afd2e4 to a7db6f7 Compare January 20, 2025 22:40
@Kocal
Copy link
Member

Kocal commented Jan 20, 2025

Thank you @yalit.

@Kocal Kocal merged commit 04f40fd into symfony:2.x Jan 20, 2025
2 checks passed
@yalit
Copy link
Contributor Author

yalit commented Jan 20, 2025

Thanks for the approval and merge!

@yalit yalit deleted the doc/update_doc_for_testing_live_component_submit_form branch January 20, 2025 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation DX LiveComponent Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Testing LiveComponent submitForm doc improvement
4 participants