lib/active_scaffold/helpers/form_column_helpers.rb
# This method decides which input to use for the given column.
# It does not do any rendering. It only decides which method is responsible for rendering.
This method decides which input to use for the given column.
It does not do any rendering. It only decides which method is responsible for rendering.
This method decides which input to use for the given column . It does not do any rendering . It only decides which method is responsible for rendering .
def active_scaffold_input_radio(column, html_options)
        record = html_options[:object]
        html_options.merge!(column.options[:html_options] || {})
        options =
          if column.association
            sorted_association_options_find(column.association, nil, record)
          else
            active_scaffold_enum_options(column, record)
          end
        selected = record.send(column.association.name) if column.association
        selected_id = selected&.id
        if options.present?
          if column.options[:add_new]
            html_options[:data] ||= {}
            html_options[:data][:subform_id] = active_scaffold_subform_attributes(column)[:id]
            radio_html_options = html_options.merge(class: html_options[:class] + ' hide-new-subform')
          else
            radio_html_options = html_options
          end
          radios = options.map do |option|
            active_scaffold_radio_option(option, selected_id, column, radio_html_options)
          end
          if column.options[:include_blank]
            label = column.options[:include_blank]
            label = as_(column.options[:include_blank]) if column.options[:include_blank].is_a?(Symbol)
            radios.prepend content_tag(:label, radio_button(:record, column.name, '', html_options.merge(id: nil)) + label)
          end
          if column.options[:add_new]
            create_new_button = radio_button_tag(html_options[:name], '', selected&.new_record?, html_options.merge(id: nil, class: html_options[:class] + ' show-new-subform'))
            radios << content_tag(:label, create_new_button << as_(:create_new)) <<
              active_scaffold_new_record_subform(column, record, html_options, skip_link: true)
          end
          safe_join radios
        else
          html = content_tag(:span, as_(:no_options), :class => "#{html_options[:class]} no-options", :id => html_options[:id])
          html << hidden_field_tag(html_options[:name], '', :id => nil)
          html << active_scaffold_new_record_subform(column, record, html_options) if column.options[:add_new]
          html
        end
      end
def active_scaffold_input_radio ( column , html_options ) record = html_options [ :object ] html_options . merge! ( column . options [ :html_options ] || { } ) options = if column . association sorted_association_options_find ( column . association , nil , record ) else active_scaffold_enum_options ( column , record ) end selected = record . send ( column . association . name ) if column . association selected_id = selected &. id if options . present? if column . options [ :add_new ] html_options [ :data ] ||= { } html_options [ :data ] [ :subform_id ] = active_scaffold_subform_attributes ( column ) [ :id ] radio_html_options = html_options . merge ( class : html_options [ :class ] + ' hide-new-subform' ) else radio_html_options = html_options end radios = options . map do | option | active_scaffold_radio_option ( option , selected_id , column , radio_html_options ) end if column . options [ :include_blank ] label = column . options [ :include_blank ] label = as_ ( column . options [ :include_blank ] ) if column . options [ :include_blank ] . is_a? ( Symbol ) radios . prepend content_tag ( :label , radio_button ( :record , column . name , '' , html_options . merge ( id : nil ) ) + label ) end if column . options [ :add_new ] create_new_button = radio_button_tag ( html_options [ :name ] , '' , selected &. new_record? , html_options . merge ( id : nil , class : html_options [ :class ] + ' show-new-subform' ) ) radios << content_tag ( :label , create_new_button << as_ ( :create_new ) ) << active_scaffold_new_record_subform ( column , record , html_options , skip_link : true ) end safe_join radios else html = content_tag ( :span , as_ ( :no_options ) , :class => "#{html_options[:class]} no-options" , :id => html_options [ :id ] ) html << hidden_field_tag ( html_options [ :name ] , '' , :id => nil ) html << active_scaffold_new_record_subform ( column , record , html_options ) if column . options [ :add_new ] html end end
This method decides which input to use for the given column.
This method decides which input to use for the given column .
column
<not_specific>
html_options
<not_specific>