demarches-normaliennes/app/views/manager/administrateurs/_form.html.erb

44 lines
1.5 KiB
Text

<%= form_for([namespace, Administrateur.new(user: User.new)], html: { class: "form" }) do |f| %>
<% if page.resource.errors.any? %>
<div id="error_explanation">
<h2>
<%= t(
"administrate.form.errors",
pluralized_errors: pluralize(page.resource.errors.count, t("administrate.form.error")),
resource_name: display_resource_name(page.resource_name, singular: true)
) %>
</h2>
<ul>
<% page.resource.errors.full_messages.each do |message| %>
<li class="flash-error"><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<% page.attributes(controller.action_name).each do |title, attributes| -%>
<fieldset class="<%= "field-unit--nested" if title.present? %>">
<% if title.present? %>
<legend><%= t "helpers.label.#{f.object_name}.#{title}", default: title %></legend>
<% end %>
<% attributes.each do |attribute| %>
<div class="field-unit field-unit--<%= attribute.html_class %> field-unit--<%= requireness(attribute) %>">
<%= render_field attribute, f: f %>
<% hint_key = "administrate.field_hints.#{page.resource_name}.#{attribute.name}" %>
<% if I18n.exists?(hint_key) -%>
<div class="field-unit__hint">
<%= I18n.t(hint_key) %>
</div>
<% end -%>
</div>
<% end %>
</fieldset>
<% end -%>
<div class="form-actions">
<%= f.submit %>
</div>
<% end %>