Ruby On Rails Form Helper with Image Submit Button


/ Published in: Ruby



Copy this code and paste it in your HTML
  1. # this code is for embedded ruby in rhtml:
  2.  
  3. <%= button_to 'Add to Cart', :action => :add_to_cart, :id => product %>
  4. # this generates a submit button:
  5. # <form method="post" action="/store/add_to_cart/3" class="button-to">
  6. # <div><input type="submit" value="Add to Cart" /></div></form>
  7. # note id = 3 in this case
  8.  
  9. # the following has the same effect as above but w/ image submit button:
  10. <%= form_tag :action => :add_to_cart, :id => product %>
  11. <%= image_submit_tag product.image_url, :class => 'image-submit' %>
  12. <%= end_form_tag %>
  13. # <form action="/store/add_to_cart/3" method="post">
  14. # <input class="image-submit" src="/images/auto.jpg?1156046942" type="image" />
  15. # </form>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.