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

Form submit with custom events is missing property of the submit button itself #5050

Open
2 tasks done
linjmeyer opened this issue Feb 6, 2025 · 1 comment
Open
2 tasks done

Comments

@linjmeyer
Copy link

linjmeyer commented Feb 6, 2025

Past Issues Searched

  • I have searched open and closed issues to make sure that the bug has not yet been reported

Issue is a Bug Report

  • This is a bug report and not a feature request, nor asking for self-hosted support

Using official Plausible Cloud hosting or self-hosting?

Self-hosting

Describe the bug

I have a get request in a form, where one of the expected params is provider and the value is the button that is clicked. The form works as expected when no event class is present, but if I add one the form submission is missing the provider param from the clicked button. There is also two hidden elements, returnUrl and __RequestVerificationToken which are always present in either case. The only one missing is the button's value.

here is an example of the form:

<form method="post" class="plausible-event-name--user-login-or-signup" action="/user/login">
    <input type="hidden" name="returnUrl" value="/return/url/example">
    <input type="hidden" name="__RequestVerificationToken" value="super-secret-token-value">
    <button type="submit" name="provider" value="Google" title="Log in using your Google account">
    Login With Google
    </button>
    <button type="submit" name="provider" value="Apple" title="Log in using your Apple account">
    Login With Apple
    </button>
</form>

I suspect it is because plausible is capturing the submission via button click, stopping it, then re-submitting it via element.submit() or element.requestSubmit() but I am not sure.

Expected behavior

The button's value won't omitted when the form is submitted via a click on a particular button.

Screenshots

No response

Environment

- OS: Windows
- Browser: Chrome
- Browser Version: 132.0.x
@linjmeyer
Copy link
Author

Easy workaround if you can edit the HTML is to just have multiple (almost) identical forms and move the button's value to a hidden input element:

<form method="post" class="plausible-event-name--user-login-or-signup" action="/user/login">
    <input type="hidden" name="returnUrl" value="/return/url/example">
    <input type="hidden" name="__RequestVerificationToken" value="super-secret-token-value">

    <input type=hidden" name="provider" value="Google" />

    <button type="submit" title="Log in using your Google account">
    Login With Google
    </button>
</form>

<form method="post" class="plausible-event-name--user-login-or-signup" action="/user/login">
    <input type="hidden" name="returnUrl" value="/return/url/example">
    <input type="hidden" name="__RequestVerificationToken" value="super-secret-token-value">

    <input type=hidden" name="provider" value="Google" />

    <button type="submit" title="Log in using your Apple account">
    Login With Apple
    </button>
</form>

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

1 participant