<%# locals: (account:, url:) %> <%= styled_form_with model: account, url: url, scope: :account, class: "flex flex-col gap-4 justify-between grow", data: { turbo: false } do |f| %>
<% unless account.new_record? %> <% if account.accountable.mode_required? %> <%= f.select :mode, Account::VALUE_MODES.map { |mode| [mode.titleize, mode] }, { label: t(".mode"), prompt: t(".mode_prompt") }, required: true %> <% end %> <% end %> <%= f.select :accountable_type, Accountable::TYPES.map { |type| [type.titleize, type] }, { label: t(".accountable_type"), prompt: t(".type_prompt") }, required: true, autofocus: true %> <%= f.text_field :name, placeholder: t(".name_placeholder"), required: "required", label: t(".name_label") %> <% if account.new_record? %> <%= f.hidden_field :institution_id %> <% else %> <%= f.collection_select :institution_id, Current.family.institutions.alphabetically, :id, :name, { include_blank: t(".ungrouped"), label: t(".institution") } %> <% end %> <%= f.money_field :balance, label: t(".balance"), required: true, default_currency: Current.family.currency %> <% if account.accountable %> <%= render permitted_accountable_partial(account, "form"), f: f %> <% end %>
<%= f.submit %> <% end %>