<%= content_tag :div, data: { model_name: @resource.model_name.to_s, resource_name: @resource.class.to_s, model_id: @resource.model.id, selected_resources_name: @resource.model_key, selected_resources: [@resource.model.id], **@resource.stimulus_data_attributes } do %> <%= form_with model: @resource.model, scope: @resource.form_scope, url: form_url, method: form_method, local: true, html: { novalidate: true }, multipart: true do |form| %> <%= render Avo::ReferrerParamsComponent.new back_path: back_path %> <%= content_tag :div, class: 'space-y-12' do %> <%= render Avo::PanelComponent.new(name: title, description: @resource.resource_description, display_breadcrumbs: @reflection.blank?, index: 0, data: { panel_id: "main" }) do |c| %> <% c.tools do %> <%= a_link back_path, style: :text, icon: 'arrow-left' do %> <%= t('avo.cancel').capitalize %> <% end %> <% if can_see_the_destroy_button? %> <%= a_link destroy_path, style: :text, color: :red, icon: 'trash', form_class: 'flex flex-col sm:flex-row sm:inline-flex', data: { turbo_confirm: t('avo.are_you_sure', item: @resource.model.model_name.name.downcase), turbo_method: :delete, control: :destroy, 'resource-id': @resource.model.id, } do %> <%= t('avo.delete').capitalize %> <% end %> <% end %> <% if can_see_the_actions_button? %> <%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view %> <% end %> <% if can_see_the_save_button? %> <%= a_button color: :primary, style: :primary, loading: true, type: :submit, icon: 'save' do %> <%= t('avo.save').capitalize %> <% end %> <% end %> <% end %> <%# Extract the main panel and display the fields here. %> <%# This way we'll be able to render the footer buttons under the main fields. %> <% if main_panel.present? %> <% c.body do %>
<% main_panel.items.each_with_index do |field, index| %> <%= render field .hydrate(resource: @resource, model: @resource.model, user: @resource.user, view: view_for(field)) .component_for_view(view_for field) .new(field: field, resource: @resource, index: index, form: form, compact: sidebar.present?) %> <% end %>
<% end %> <% end %> <% if sidebar.present? %> <% c.sidebar do %> <%= render sidebar_component form: form %> <% end %> <% end %> <% if Avo.configuration.buttons_on_form_footers %> <% c.footer_tools do %>
<%= a_link back_path, style: :text, icon: 'arrow-left' do %> <%= t('avo.cancel').capitalize %> <% end %> <% if can_see_the_save_button? %> <%= a_button color: :primary, style: :primary, loading: true, type: :submit, icon: 'save' do %> <%= t('avo.save').capitalize %> <% end %> <% end %>
<% end %> <% end %> <% end %> <%= content_tag :div, class: 'space-y-12' do %> <% @resource.get_items.each_with_index do |item, index| %> <% next if item.nil? %> <%= render Avo::ItemSwitcherComponent.new resource: @resource, item: item, index: index + 1, view: @view, form: form %> <% end %> <% end %> <% end %> <% end %> <% end %>