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
14
15
16
# File 'lib/datagrid/form_builder.rb', line 7

def datagrid_filter(filter_or_attribute, options = {}, &block)
  filter = datagrid_get_filter(filter_or_attribute)
  options = {
    **filter.input_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, text = nil, **options, &block) ⇒ Object

Returns a form label html for the corresponding filter name


19
20
21
22
# File 'lib/datagrid/form_builder.rb', line 19

def datagrid_label(filter_or_attribute, text = nil, **options, &block)
  filter = datagrid_get_filter(filter_or_attribute)
  label(filter.name, text || filter.header, **filter.label_options, **options, &block)
end