<% institution = @institution || student.institution %>
<% form_url = student.persisted? ? institution_student_path(institution, student) : institution_students_path(institution) %>
<%= form_with(model: student, url: form_url, remote: true) do |form| %>
  <% if student.errors.any? %>
    <div style="color: red">
      <h2><%= pluralize(student.errors.count, "error") %> prohibited this student from being saved:</h2>

      <ul>
        <% student.errors.each do |error| %>
          <li><%= error.full_message %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <div>
    <%= form.label :first_name, style: "display: block" %>
    <%= form.text_field :first_name %>
  </div>

  <div>
    <%= form.label :last_name, style: "display: block" %>
    <%= form.text_field :last_name %>
  </div>

  <div>
    <%= form.label :email, style: "display: block" %>
    <%= form.text_field :email %>
  </div>

  <div class="field">
  <%= form.label :phone_number, style: "display: block" %>
  <%= form.text_field :phone_number %>
</div>

<div class="field">
  <%= form.label :place, style: "display: block" %>
  <%= form.text_field :place %>
</div>

<div class="field">
  <%= form.label :age, style: "display: block" %>
  <%= form.number_field :age %>
</div>

<div class="field">
  <%= form.label :photo, "Upload Photo", style: "display: block" %>
  <%= form.file_field :photo, accept: "image/*" %>
</div>

  <div>
    <%= form.submit %>
  </div>
<% end %>
