-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Environment
- Elixir version (elixir -v): 1.18.4
- Phoenix version (mix deps): 1.7.19
- Phoenix LiveView version (mix deps):
main - Operating system: Mac
- Browsers you attempted to reproduce this bug on (the more the merrier): N/A
- Does the problem persist after removing "assets/node_modules" and trying again? Yes/no: N/A
N/A because it's in the test helper module Phoenix.LiveViewTest.
Actual behavior
When we are using follow_trigger_action, we submit form directly as HTTP submission. According to docs:
Imagine you have a LiveView that sends an HTTP form submission. Say that it sets the
phx-trigger-actionto true, as a response to a submit event.
However, as-is it does not submit data from hidden inputs.
Reproduction for both scenarios (neither of new test cases pass as-is): brain-geek@f702ece
Expected behavior
If I have a form in LiveView which submits HTTP POST:
<form
id="trigger-form-hidden-values"
phx-trigger-action={@trigger_action}
>
<input name="key" type="hidden" value="value" />
</form>and in tests I write
view |> form("#trigger-form-phx-value") |> follow_trigger_action(conn)This should submit %{"key" => "value"} but it does not. From this logic, it should also add all the values from other unspecified inputs, as in this case it would be reproducing the behavior of form submission. The hidden field here is just the most glaring use case.
I would love to fix this myself, however if would be great if someone could confirm that this is not intended by design, and if implicitly adding those hidden fields to follow_trigger_action submission makes sense, or some other solution should be used.
From what I understand, for other helpers this can be bypassed by explicitly adding those values as phx-value* fields in form definition, however for form submission such a workaround does not exist.