<%= form_with(model: recipe) do |form| %>
  <% if recipe.errors.any? %>
    <div style="color: red">
      <h2><%= pluralize(recipe.errors.count, "error") %> prohibited this recipe from being saved:</h2>

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

  <div class="mb-3">
    <%= form.label :name, class: 'form-label' %>
    <%= form.text_field :name, class: "form-control" %>
  </div>

  <div class="mb-3">
    <%= form.label :category_id, class: 'form-label' %>
    <%= form.select :category_id, options_for_select(Category.all.map { |category| [category.name, category.id] }), {}, class: 'form-select' %>
  </div>

  <div class="mb-3">
    <%= form.label :photo, class: 'form-label' %>
    <%= form.file_field :photo, class: 'form-control' %>
  </div>

  <div class="mb-3">
    <%= form.label :description, class: 'form-label' %>
    <%= form.text_area :description, class: 'form-control' %>
  </div>

  <div class="mb-3">
    <%= form.label :ingredients, class: 'form-label' %>
    <%= form.text_area :ingredients, class: 'form-control' %>
  </div>

  <div class="mb-3">
    <%= form.label :instructions, class: 'form-label' %>
    <%= form.text_area :instructions, class: 'form-control' %>
  </div>

  <div class="mb-3">
    <%= form.submit class: 'btn btn-primary' %>
  </div>
<% end %>
