Class: DynamicScaffold::Form::Item::TwoOptions

Inherits:
Base
  • Object
show all
Defined in:
lib/dynamic_scaffold/form/item/two_options.rb

Direct Known Subclasses

TwoOptionsWithBlock

Instance Attribute Summary

Attributes inherited from Base

#multiple, #name, #parent_item

Instance Method Summary collapse

Methods inherited from Base

create, #default, #default_value, #errors, #extract_parameters, #if, #insert, #label, #label?, #needs_rendering?, #note, #notes?, #proxy, #proxy_field, #render_label, #render_notes, #type?, #unique_name, #unless

Constructor Details

#initialize(config, type, *args) ⇒ TwoOptions

Returns a new instance of TwoOptions.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dynamic_scaffold/form/item/two_options.rb', line 7

def initialize(config, type, *args)
  name = args.shift
  # rubocop:disable Style/IdenticalConditionalBranches
  if args[args.length - 2].is_a?(Hash)
    html_attributes = args.extract_options!
    @options = args.extract_options!
  else
    html_attributes = {}
    @options = args.extract_options!
  end
  # rubocop:enable Style/IdenticalConditionalBranches

  @args = args
  super(config, type, name, html_attributes)
end

Instance Method Details

#render(view, form, classnames = nil) ⇒ Object



23
24
25
26
# File 'lib/dynamic_scaffold/form/item/two_options.rb', line 23

def render(view, form, classnames = nil)
  html_attributes = build_html_attributes(classnames)
  form.public_send(@type, @name, *build_args(view, @args), @options, html_attributes)
end