Class: DynamicScaffold::Form::Item::SingleOption

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

Constant Summary

Constants inherited from Base

Base::ITEM_TYPES

Instance Attribute Summary

Attributes inherited from Base

#name

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?, #unless

Constructor Details

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

Returns a new instance of SingleOption.



5
6
7
8
9
10
# File 'lib/dynamic_scaffold/form/item/single_option.rb', line 5

def initialize(config, type, *args)
  name = args.shift
  html_attributes = args.extract_options!
  @args = args
  super(config, type, name, html_attributes)
end

Instance Method Details

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



12
13
14
15
16
17
# File 'lib/dynamic_scaffold/form/item/single_option.rb', line 12

def render(_view, form, classnames = nil)
  html_attributes = build_html_attributes(classnames)
  # Retain the value of the password field on error.
  html_attributes[:value] = form.object.public_send(@name) if @type == :password_field
  form.public_send(@type, @name, *@args, html_attributes)
end