<%- elem.insert(:before).each do |block| -%>
<%= self.instance_exec(@record, &block) %>
<%-end-%>
<% if elem.type? :collection_check_boxes %>
<%= elem.render(self, form) do |cb|%>
<%= cb.label class: 'form-check-label' do%>
<%= cb.check_box class: 'form-check-input' %> <%= cb.text %>
<%end%>
<%end%>
<% elsif elem.type? :collection_radio_buttons %>
<%= elem.render(self, form) do |cb|%>
<%= cb.label class: 'form-check-label' do%>
<%= cb.radio_button class: 'form-check-input' %> <%= cb.text %>
<%end%>
<%end%>
<% elsif elem.type? :carrierwave_image %>
<%- image = form.object.public_send(elem.name) -%>
<% if elem.options[:removable] %>
<% end %>
<%- if elem.cropper.present? -%>
<%= form.hidden_field "cropper_#{elem.name}", class: "js-ds-image-cropper", data:{options: elem.cropper.to_json} %>
<%- end -%>
<%= form.hidden_field "remove_#{elem.name}", value: "1", disabled:"disabled", class: 'js-ds-image-remove-flag' if elem.options[:removable]%>
<%= elem.render(self, form, 'form-control-file js-ds-image') do |attr|%>
<%= form.file_field(elem.name, attr) %>
<%end%>
<%= form.hidden_field "#{elem.name}_cache" %>
<% elsif elem.type? :globalize_fields %>
<% elem.locales.each do |locale, name| %>
<%- locale_errors = elem.locale_errors(locale, form) -%>
<%= form.globalize_fields_for(locale) do |gform|%>
<%= tag.span(elem.lang_attributes('ds-globalize-lang')) do%>
<%= name %>
<%end%>
<%= elem.render(self, gform, class_names('form-control', {'is-invalid': locale_errors.present?})) %>
<%= render_form_errors(locale_errors) -%>
<%end%>
<% end %>
<% elsif elem.type? :cocoon %>
<%= form.fields_for elem.name, elem.build_children(@record) do |child_form| %>
<%= render 'dynamic_scaffold/bootstrap/form/cocoon', f: child_form, items: elem.form.items, depth: depth %>
<% end %>
<%= link_to_add_association(
"#{dynamic_scaffold_icon(:add)} #{elem.add_text}".html_safe,
form,
elem.name,
class: 'btn btn-outline-secondary btn-sm',
partial: 'dynamic_scaffold/bootstrap/form/cocoon',
render_options: { locals: { items: elem.form.items, depth: depth } }
) %>
<% elsif elem.type?(:date_select, :datetime_select) %>
<%== elem.render(self, form, class_names('form-control mr-2', {'is-invalid': errors.present?}))
.gsub(/ — /, ' ')
.gsub(/ : /, ':')
%>
<% else %>
<%= elem.render(self, form, class_names('form-control', {'is-invalid': errors.present?})) %>
<% end %>
<%- elem.insert(:after).each do |block| -%>
<%= self.instance_exec(@record, &block) %>
<%-end-%>