Sha256: 1b2842dbff16537325f1b33f06267b9b1b94b5e1eb0cddfe7fdb1207edc06f97

Contents?: true

Size: 1.46 KB

Versions: 5

Compression:

Stored size: 1.46 KB

Contents

<% current = f.object.find_or_create_a_field_by( field_setting.id, 'selection' ) %>
<%= f.simple_fields_for "selections_attributes[]", current do |ff| %>
	<% if ff.object.choices.any? %>
		<%= ff.input :choice_ids,
					label: field_setting.name.capitalize,
					hint: prepare_description_for_selections_form_hint(field_setting),
					as: :select,
					collection: field_setting.choices.order(:label),
					label_method: :label,
					value_method: :id,
					selected: ff.object.choices.ids,
					include_blank: field_setting.allow_null ? '.' : false,
					input_html: { class: "select2-item #{ "select2-item-include-blank" if field_setting.allow_null }"  } %>
	<% else %>
		<%= ff.input :choice_ids,
					label: field_setting.name.capitalize,
					hint: prepare_description_for_selections_form_hint(field_setting),
					as: :select,
					collection: field_setting.choices.order(:label),
					label_method: :label,
					value_method: :id,
					selected: ( field_setting.default_choice.id if !field_setting.allow_null && !field_setting.default_choice_id.nil?),
					include_blank: field_setting.allow_null ? '.' : false,
					input_html: { class: "select2-item #{ "select2-item-include-blank" if field_setting.allow_null }"  } %>
	<% 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 %>

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
binda-0.1.8 app/views/binda/fieldable/form_item_selections/_form_item_selection.html.erb
binda-0.1.7 app/views/binda/fieldable/form_item_selections/_form_item_selection.html.erb
binda-0.1.6 app/views/binda/fieldable/form_item_selections/_form_item_selection.html.erb
binda-0.1.5 app/views/binda/fieldable/form_item_selections/_form_item_selection.html.erb
binda-0.1.4 app/views/binda/fieldable/form_item_selections/_form_item_selection.html.erb