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

hx-boosted forms issue requests even when method="dialog" or formmethod="dialog" #2554

Open
PizzasBear opened this issue May 18, 2024 · 2 comments

Comments

@PizzasBear
Copy link
Contributor

As I understand it, hx-boost is meant only to replace standard browser requests with htmx ajax ones.
When using method="dialog" or formmethod="dialog" the browser doesn't issue a request, so hx-boost shouldn't to intervene.

Example:

<dialog open>
    <form hx-boost="true" method="POST" action="create">
        <h1>Create a new thing</h1>
        <p>
            <label>
                Name:
                <input type="text" name="name">
            </label>
        </p>
        <p>
            <button>Create</button>
            <button formmethod="dialog" formnovalidate>Cancel</button>
        </p>
    </form>
</dialog>

When the cancel button is pressed, this will issue a request contrary to browser behaviour.

@fiik346
Copy link

fiik346 commented May 20, 2024

You just use hx-boost="false" on the dialog

@Tortoaster
Copy link

There was a recent-ish related issue on the topic of formmethod="dialog" (#1866), not specific to boosted forms. The linked pull request changed the way HTMX handles it by having it send a POST request rather than an invalid DIALOG request. While that is an improvement of sorts, I think it would be more intuitive to follow the spec and close the dialog without sending a request.

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

No branches or pull requests

3 participants