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

Add [data-formbuilder] and Psr15DialogFormResponse #5618

Merged
merged 1 commit into from
Aug 14, 2023

Conversation

dtdesign
Copy link
Member

@dtdesign dtdesign commented Aug 12, 2023

This PR allows fully automated handling of PSR-15 based form builder dialogs with support for redirects and page reloads. Adding the data-formbuilder attribute in combination with data-endpoint on a button-like element will enable the automated click handling, eventually invoking the PSR-15 dialog form.

<button data-formbuilder data-endpoint="{$endpointUrl}">Click me</button>

The PHP endpoint can utilize the Psr15DialogFormResponse to redirect(string $url) or reload() the page.

return Psr15DialogFormResponse::redirect($someUrl)->toResponse();

The client implementation will trigger the formBuilder:result event on success, providing the response data using the detail property of the event. This event can be cancelled with .preventDefault() which will prevent the aforementioned redirect() or reload() taking place.

@dtdesign dtdesign merged commit 2700eb7 into master Aug 14, 2023
8 checks passed
@dtdesign dtdesign deleted the psr-15-dialog-form-button branch August 14, 2023 09:40
dtdesign added a commit that referenced this pull request Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants