Class: DynamicFieldsets::RadioField

Inherits:
Field
  • Object
show all
Defined in:
app/models/dynamic_fieldsets/radio_field.rb

Overview

Radio buttons input

Instance Method Summary collapse

Methods inherited from Field

#collect_default_values, #collect_field_records_by_fsa_and_fsc, descendant_collection, descendants, #display_type, #form_footer_partial, #form_header_partial, #form_partial, #get_value_for_show, #get_values_using_fsa_and_fsc, #has_defaults?, #html_attribute_hash, #in_use?, #show_footer_partial, #show_header_partial, #show_partial, #show_partial_locals, #update_field_records, #use_form_footer_partial?, #use_form_header_partial?, #use_show_footer_partial?, #use_show_header_partial?, #uses_field_options?

Instance Method Details

#form_partial_locals(args) ⇒ Hash

Note that the radio buttons need special data per field option output contains information for each of the field options for the radio field

Returns:

  • (Hash)

    Data needed for the radio buttons partial



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/dynamic_fieldsets/radio_field.rb', line 11

def form_partial_locals(args)
  output = super
  output[:options] = []
  field_options.each do |option|
    output[:options] << {
      :name => "#{DynamicFieldsets.config.form_fieldset_associator_prefix}#{args[:fsa].id}[#{DynamicFieldsets.config.form_field_prefix}#{args[:fieldset_child].id}]",
      :value => option.id.to_s,
      :checked => value_or_default_for_form(args[:values]).eql?(option.id.to_s),
      :html_attributes => html_attribute_hash,
      :label => option.name,
    }
  end
  return output
end