Ruby Quicktips Logo

Ruby Quicktips

Random Ruby and Rails tips.
This blog is dedicated to deliver short, interesting and practical tidbits of the Ruby language and Ruby on Rails framework. Read more...

Your submissions are more than welcome!
Jan 14 ’10

Disabling input fields on a form based on a condition

You may know about the :disabled option for form elements such as buttons, text-fields etc:

submit_tag "Pay", :disabled => true

Did you know, you can pass any boolean expression as a value?

submit_tag "Pay", :disabled => @cart.empty?

(via Using conditions in Form Helpers of Rails)

11 notes 0 comments

  1. noplans reblogged this from rubyquicktips
  2. rubyquicktips posted this

Comments

You can use HTML tags for formatting. Wrap code in <code> tags and multiple lines of code in <pre><code> tags.

blog comments powered by Disqus