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

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

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) ⇒ SingleOption

Returns a new instance of SingleOption.



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

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



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

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, *build_args(view, @args), html_attributes)
end