Skip to content
Browse files

Ability to pass label text explicitly and overwrite the one defined i…

…n grid
  • Loading branch information...
1 parent 8c67eaf commit ddb179e1eefc12f8b1e31e8037ea65ed6bd877a6 @bogdan committed Jan 15, 2014
Showing with 8 additions and 2 deletions.
  1. +3 −2 lib/datagrid/form_builder.rb
  2. +5 −0 spec/datagrid/form_builder_spec.rb
View
5 lib/datagrid/form_builder.rb
@@ -11,9 +11,10 @@ def datagrid_filter(filter_or_attribute, options = {})
end
# Returns a form label html for the corresponding filter name
- def datagrid_label(filter_or_attribute, options = {}, &block)
+ def datagrid_label(filter_or_attribute, options_or_text = {}, options = {}, &block)
filter = datagrid_get_filter(filter_or_attribute)
- label(filter.name, filter.header, options, &block)
+ text, options = options_or_text.is_a?(Hash) ? [filter.header, options_or_text] : [options_or_text, options]
+ label(filter.name, text, options, &block)
end
protected
View
5 spec/datagrid/form_builder_spec.rb
@@ -473,5 +473,10 @@ class MyTemplate
'<label class="foo" for="report_name">The Name</label>'
)
end
+ it "should support explicit label" do
+ view.datagrid_label(:name, "The Name").should equal_to_dom(
+ '<label for="report_name">The Name</label>'
+ )
+ end
end
end

0 comments on commit ddb179e

Please sign in to comment.
Something went wrong with that request. Please try again.