Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SuperFormBuilder < ActionView::Helpers::FormBuilder
- # Create an array of helpers to override with our label builder
- helpers = field_helpers +
- %w{date_select datetime_select time_select} +
- %w{collection_select select country_select time_zone_select} -
- %w{hidden_field label fields_for} # Don't decorate these
- helpers.each do |name|
- define_method(name) do |field, *args|
- # Get the hash option (EG the field involved)
- options = args.last.is_a?(Hash) ? args.pop : {}
- # Create a label for that field
- label = label(field, options[:label], :class => options[:label_clas])
- # Wrap label in paragraph, include the original helper EG: text-field
- @template.content_tag(:p, label +'<br/>' + super) #wrap with a paragraph
- end
- end
- # Override the submit button
- define_method("submit") do |field|
- @template.content_tag(:p, "Test")
- end
- end
Add Comment
Please, Sign In to add comment