<% collapse_id = "collapse_field_#{rand(1000)}" %>
<% toolbar = capture do %> <% if f.object.custom_fields.empty? %> <%= link_to icons(:delete), '#', title: 'Remove Field', class: 'remove_custom_fields btn btn-link btn-icon text-danger' %> <% else %> <%= link_to icons(:delete), '#', title: 'Remove field and associated data', class: 'remove_custom_fields btn btn-link btn-icon text-danger', data: {confirm: 'There is already data stored with this field. Are you sure you want to delete it?'} %> <% end %> <% end %> <%= f.hidden_field :_destroy, class: '_destroy' %> <%= panel toolbar: toolbar, title: f.object.new_record? ? 'New Field' : link_to(icon_label('icon-arrow-right3', f.object.field_type), "\##{collapse_id}", title: 'Show/Hide Detail', data: {toggle: 'collapse'} ) do %> <% unless f.object.new_record? %> <% sample = CustomField.new %> <% sample.custom_field_def = f.object %> <%= f.simple_fields_for sample do |builder| %> <% field = builder.object %> <%= render "dm_core/admin/custom_fields/#{field.field_type}", field: field, f: builder, disabled: true %> <% end %> <% end %>
<%= f.input :field_type, collection: CustomFieldDef::FIELD_TYPES, required: true, input_html: {class: 'width_50_percent'} %> <%= locale_tabs do |locale| %> <%= f.input "label_#{locale}", label: 'Label', hint: 'Text used to label the field' %> <%= f.input "description_#{locale}", label: 'Description', as: :text, input_html: {style: "height: 100px;"}, hint: 'Text shown above the field, such as an introductory paragraph. Markdown format' %> <% end %> <%= f.input :required, as: :boolean, label: 'Required' %> <%= f.input :choice_list, label: 'Choice List', hint: 'Comma seperated list, used by Checboxes, Radio Buttons and Drop Downs', input_html: {class: 'width_50_percent'} %> <%= f.input :name, label: 'Export Name', hint: "Name of the column in exported data and reports. The label will be used if blank", input_html: {class: 'width_50_percent'} %>
<% end %>