PhoenixIntegration.Requests.submit_form

You're seeing just the function submit_form, go back to PhoenixIntegration.Requests module for more information.
Link to this function

submit_form(conn, fields, opts \\ %{})

View Source

Finds a form in conn.resp_body, fills out the fields with the given data, requests the form's action and returns the resulting conn.

Parameters

  • conn should be a conn returned from a previous request that rendered some html. The functions are designed to pass the conn from one call into the next via pipes.
  • fields a map of fields and data to be written into the form before submitting its action.
  • opts A map of additional options
    • identifier indicates which link to find in the html. Defaults to nil. Valid values can be in the following forms:
      • "/some/path" specify the link's href starting with a "/" character
      • "http://www.example.com/some/uri", specify the href as full uri starting with either "http" or "https"
      • "#element-id" specify the html element id of the link you are looking for. Must start start with the "#" character (same as css id specifier).
      • "Some Text" specify text contained within the link you are looking for.
    • :method - restricts the forms searched to those whose action uses the given method (such as "post" or "put"). Defaults to nil;
    • :finder - finding string passed to Floki.find. Defaults to "form"

If no opts.identifier is specified, the first form that makes sense is used. Unless you have multiple forms on your page, this often is the most understandable pattern.

If no appropriate form is found, submit_form raises an error.

Any redirects are not followed.

Example:

  # fill out a form and submit it
  get( conn, thing_path(conn, :edit, thing) )
  |> submit_form( %{ thing: %{
      name: "Updated Name",
      some_count: 42
    }})
  |> assert_response( status: 302, to: thing_path(conn, :show, thing) )