Pregunta

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?

¿Fue útil?

Solución 2

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>

Otros consejos

<%= 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>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top