Help with form id

hello im trying to set an id on a phoenix form and cannot find in the docs where to set it
i am trying to use the google recaptcha api
i have

<div id="register">
<h1>Create a Provider account</h1>

<%= form_for @changeset, registration_path(@conn, :create), fn f -> %>
<%= if f.errors != [] do %>
<div class="alert alert-danger">
    <p>Oops, something went wrong! Please check the errors below:</p>
</div>
<% end %>

<div class="form-group">
    <label>Email</label>
    <%= email_input f, :email, class: "form-control" %>
    <%= error_tag f, :email %>
</div>



<div class="form-group">
    <button
            class="g-recaptcha"
            data-sitekey="6LeM0R0UAAAAAN4LPVhMhDNKGol4Ayc4yJmODZTn"
            data-callback="sendRegistration">
        Submit
    </button>
    <%= # submit "Signup", class: "btn btn-primary" %>
</div>
<% end %>
</div>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script>
    function  sendRegistration(){
        document.getElementById("registration-form").submit();
        alert("sent")
    }
</script>
1 Like

You want HTML id? Pass it as a an option for the form_for

form_for @changeset, registration_path(@conn, :create), [id: "some-id"], fn f

s. Phoenix.HTML.Form — Phoenix.HTML v4.0.0

Other options will be passed as html attributes. ie, class: “foo”, id: “bar”

thx i tried that it didnt work b4 pebkec

it works, I checked :slight_smile: