Rails form view with a send button

73 views Asked by At

I have a form generated by scaffold in my _form.html.erb

<%= form_for @survey do |f| %>

  <%= f.label :name %><br />
  <%= f.text_field :name %>
  <%= f.submit "Send", class: "btn btn-red span3" %>

<% end %>

my submit input produces:

<input class="btn btn-red span3" name="commit" type="submit" value="Send">

I want to produce a button instead a input. Like this:

<button class="btn btn-red span3" name="commit" type="submit">Send</button>

Any tip?

2

There are 2 answers

0
ricardocaldeira On BEST ANSWER

I discovered a simple way

<%= button_tag "Send", class: "btn btn-red span3", name: "commit" %>

produces:

<button class="btn btn-red span3" name="commit" type="submit">Send</button>
0
Salil On
<%= content_tag :button, type: :submit, class: "btn btn-red span3" do %>
   Send
<% end %>

Produces following HTML

<button class="btn btn-red span3" type="submit">
   Send
</button>