Skip to content
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

RFC about using Symfony UX Turbo #13

Merged
merged 2 commits into from
Jan 2, 2024
Merged

RFC about using Symfony UX Turbo #13

merged 2 commits into from
Jan 2, 2024

Conversation

jrmgx
Copy link
Contributor

@jrmgx jrmgx commented Dec 11, 2023

Hello, and thank you for your work.

In my project I already use Symfony UX Turbo, so when I choose to use Dynamic Forms (and implement the JavaScript part) I saw an opportunity to have both working together.

In this PR I updated the README, but it's more to have a place to show you the idea and implementation.

This may even lead to a better integration between this package and Turbo Frame.

Let me know.

Copy link
Member

@bocharsky-bw bocharsky-bw left a comment

Choose a reason for hiding this comment

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

I like this idea in general, though have some comments

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@jrmgx
Copy link
Contributor Author

jrmgx commented Dec 29, 2023

I have fixed your comments, please let me know if it's good for you.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
+ $submitButton = $feedbackForm->get('submit');
+ if (!$submitButton->isClicked()) {
+ return $this->render('feedback.html.twig', ['feedbackForm' => $feedbackForm]);
+ }
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this should be below "Your code here"? I mean, we still want to execute all that custom code in below, but just return a different reponse, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this scenario, this code is here to handle the 'onchange' => 'this.form.submit()' (auto-submit) part of the form. So it should not trigger the business code, it just re-renders the form with updated state.

// Your code here
// ...

return $this->redirectToRoute('home');
Copy link
Member

Choose a reason for hiding this comment

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

And if so, maybe better to do the opposite.... if $submitButton->isClicked() is clicked - do this return $this->redirectToRoute('home');.

Otherwise, the execution will continue and call that return $this->render('feedback.html.twig', ['feedbackForm' => $feedbackForm]); below.

Wdyt?

Copy link
Member

@bocharsky-bw bocharsky-bw left a comment

Choose a reason for hiding this comment

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

OK, I think this is good to go!

Thank you for working on it!

@bocharsky-bw bocharsky-bw merged commit d8812e2 into SymfonyCasts:main Jan 2, 2024
11 checks passed
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.

2 participants