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

Consider buttons with a name and value as possible input for a form on follow_form #58

Open
mrnovalles opened this issue Aug 19, 2021 · 1 comment

Comments

@mrnovalles
Copy link

mrnovalles commented Aug 19, 2021

I have a use case where form has multiple buttons each of them pointing at the same controller action but each with a separate name and value:

<button class="btn btn-sm btn-danger" id="mark-released" name="action[is_released]" type="submit" value="true">Release</button>
<button class="btn btn-sm btn-danger" id="mark-released" name="action[is_deployed]" type="submit" value="true">Deployed</button>

In my tests, with the current implementation of follow_form I can never get the value of the button to be set as:

follow_form(conn, %{
  action: %{is_deployed: "true"},
  metadata: %{"#{version0.id}": "true", "#{version1.id}": "true"},
},

We currently use v0.7.0 but if this is of interest I'd be willing to submit a patch to 0.7.0 and higher versions.
From a quick look at it in 0.7.0, it requires adding some lines in request.ex

  defp get_form_data(form) do
    %{}
    |> build_form_by_type(form, "input")
    |> build_form_by_type(form, "textarea")
    |> build_form_by_type(form, "select")
    |> build_form_by_type(form, "button")
  end

...

  defp get_input_value(input, "button") do
    Floki.attribute(input, "value")
  end

I can see this would be very different for current HEAD, so I wanted to check before jumping into the code currently in master.

@boydm
Copy link
Owner

boydm commented Sep 25, 2021

@zucaritask I'm open to this. Would want the fix in master tho.

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

2 participants