<% 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 %>
<% end %>