public
Description: Not needed in Rails 2.3, but if you're still < 2.3, this plugin adds the ability to create disabled option tags with your form helpers
Homepage:
Clone URL: git://github.com/tekin/option_tags_will_disable.git
name age message
file MIT-LICENSE Tue Nov 11 07:13:26 -0800 2008 Initial commit [tekin]
file README.rdoc Fri Jan 02 08:14:23 -0800 2009 Updated README [tekin]
file Rakefile Tue Nov 11 07:13:26 -0800 2008 Initial commit [tekin]
file init.rb Fri Nov 14 02:27:11 -0800 2008 Renamed files and removed unnecessary tasks folder [tekin]
directory lib/ Fri Jan 02 08:14:10 -0800 2009 Updated to allow a Proc to be used to identify ... [tekin]
directory test/ Fri Jan 02 08:14:10 -0800 2009 Updated to allow a Proc to be used to identify ... [tekin]
README.rdoc

OptionTagsWithDisabled

Enhancements to form option tag helpers.

Disabled option tags

Disabled option tags can now be specified:

        <%= options_for_select(['Please choose a size', 'small', 'medium', 'large'], nil, 'medium' ) %>

Gives you:

        <option value="Please choose a size">Please choose a size</option>
        <option value="s">small</option>
        <option value="m" disabled="disabled">medium</option>
        <option value="l">large</option>

You can specify a single value or an array of disabled values.

Proc for selected and disabled option tags

options_from_collection_for_select now accepts a proc to identify selected and/or disabled attributes:

  options_from_collection_for_select(@products, :id, :name, nil, lambda{|p| p.in_stock? })

Would produce:

<option value="s">small</option> <option value="m" disabled="disabled">medium</option> <option value="l">large</option> <option value="xl">extra large</option>

Where any elements of the collection that are out of stock would be disabled.

Copyright © 2008 Tekin Suleyman, released under the MIT license