Posted By

brianjlandau on 03/10/08


Tagged

form textmate rails ruby helpers ActionView


Versions (?)

FormOptionsHelpers => :include_blank


 / Published in: Other
 

  1. module ActionView::Helpers::FormOptionsHelper
  2.  
  3. def options_for_select_with_include_blank(container, selected = nil, include_blank = false)
  4. options = options_for_select_without_include_blank(container, selected)
  5. if include_blank
  6. options = "<option value="">#{include_blank if include_blank.kind_of?(String)}</option>n" + options
  7. end
  8. options
  9. end
  10. alias_method_chain :options_for_select, :include_blank
  11.  
  12. def options_from_collection_for_select_with_include_blank(collection, value_method, text_method, selected = nil, include_blank = false)
  13. options = options_from_collection_for_select_without_include_blank(collection, value_method, text_method, selected)
  14. if include_blank
  15. options = "<option value="">#{include_blank if include_blank.kind_of?(String)}</option>n" + options
  16. end
  17. options
  18. end
  19. alias_method_chain :options_from_collection_for_select, :include_blank
  20.  
  21. end
  22.  

Report this snippet  

You need to login to post a comment.