We Recommend

Beginning Ruby: From Novice to Professional Beginning Ruby: From Novice to Professional
Beginning Ruby is a thoroughly contemporary guide for every type of reader wanting to learn Ruby, from novice programmers to web developers to Ruby newcomers. It starts by explaining the principles behind object-oriented programming and within a few chapters builds toward creating a genuine Ruby application.


Posted By

newtonapple on 08/20/06


Tagged

ruby rubyonrails erb rhtml


Versions (?)


Who likes this?

6 people have marked this snippet as a favorite

xurde
ryanprel
bbebop
bluefuton
chrisaiv
vali29


Ruby On Rails Form Helper with Image Submit Button


Published in: Ruby 


  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 

You need to login to post a comment.