Module: Datagrid::FormBuilder

Defined in:
lib/datagrid/form_builder.rb

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Instance Method Details

#datagrid_filter(filter_or_attribute, options = {}, &block) ⇒ Object

Returns a form input html for the corresponding filter name


7
8
9
10
11
12
13
# File 'lib/datagrid/form_builder.rb', line 7

def datagrid_filter(filter_or_attribute, options = {}, &block)
  filter = datagrid_get_filter(filter_or_attribute)
  options = add_html_classes(options, filter.name, datagrid_filter_html_class(filter))
  # Prevent partials option from appearing in HTML attributes
  options.delete(:partials) # Legacy option
  self.send(filter.form_builder_helper_name, filter, options, &block)
end

#datagrid_label(filter_or_attribute, options_or_text = {}, options = {}, &block) ⇒ Object

Returns a form label html for the corresponding filter name


16
17
18
19
20
# File 'lib/datagrid/form_builder.rb', line 16

def datagrid_label(filter_or_attribute, options_or_text = {}, options = {}, &block)
  filter = datagrid_get_filter(filter_or_attribute)
  text, options = options_or_text.is_a?(Hash) ? [filter.header, options_or_text] : [options_or_text, options]
  label(filter.name, text, options, &block)
end