<%# HEADING %>
<%= field_setting.name.capitalize %>
<% unless field_setting.description.blank? %> <%= field_setting.description %> <% end %> <% if field_setting.choices.any? %> <%# - - - - - - - - - - - - %> <%# RADIO %> <%# - - - - - - - - - - - - %> <% if field_setting.field_type === 'radio' %> <% current = @component.find_or_create_a_field_by( field_setting.id, 'radio' ) %> <%= f.simple_fields_for "radios_attributes[]", current do |ff| %> <% if ff.object.choices.any? %> <%= ff.input :choice_ids, as: :radio_buttons, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, checked: ff.object.choices.first.id, include_blank: false %> <% else %> <%= ff.input :choice_ids, as: :radio_buttons, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, checked: field_setting.default_choice.id, include_blank: false %> <% end %> <%= ff.input :field_setting_id, as: :hidden, input_html: { value: field_setting.id } %> <%= ff.input :id, as: :hidden, input_html: { value: ff.object.id } %> <%= ff.input :fieldable_id, as: :hidden %> <%= ff.input :fieldable_type, as: :hidden %> <% end %> <%# - - - - - - - - - - - - %> <%# SELECT %> <%# - - - - - - - - - - - - %> <% elsif field_setting.field_type === 'select' %> <% current = @component.find_or_create_a_field_by( field_setting.id, 'select' ) %> <%= f.simple_fields_for "selects_attributes[]", current do |ff| %> <% if ff.object.choices.any? %> <%= ff.input :choice_ids, as: :select, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, selected: ff.object.choice_ids, include_blank: false %> <% else %> <%= ff.input :choice_ids, as: :select, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, selected: field_setting.default_choice.id, include_blank: false %> <% end %> <%= ff.input :field_setting_id, as: :hidden, input_html: { value: field_setting.id } %> <%= ff.input :id, as: :hidden, input_html: { value: ff.object.id } %> <%= ff.input :fieldable_id, as: :hidden %> <%= ff.input :fieldable_type, as: :hidden %> <% end %> <%# - - - - - - - - - - - - %> <%# CHECKBOX %> <%# - - - - - - - - - - - - %> <% elsif field_setting.field_type === 'checkbox' %> <% current = @component.find_or_create_a_field_by( field_setting.id, 'checkbox' ) %> <%= f.simple_fields_for "checkboxes_attributes[]", current do |ff| %> <% if ff.object.choices.any? %> <%= ff.input :choice_ids, as: :check_boxes, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, checked: ff.object.choice_ids, include_blank: false %> <% else %> <%= ff.input :choice_ids, as: :check_boxes, collection: field_setting.choices.order(:label), label_method: :label, value_method: :id, checked: field_setting.default_choice.id, include_blank: false %> <% end %> <%= ff.input :field_setting_id, as: :hidden, input_html: { value: field_setting.id } %> <%= ff.input :id, as: :hidden, input_html: { value: ff.object.id } %> <%= ff.input :fieldable_id, as: :hidden %> <%= ff.input :fieldable_type, as: :hidden %> <% end %> <% end %> <% else %>

Sorry, no choice is available. <% if current_user.is_superadmin %> Please ensure you setup at least two possible choices in the field group setup. <% else %> Please contact the administrator. <% end %>

<% end %>