Skip to content

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

@mrnovalles

Description

@mrnovalles

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions