Files
growstuff/app/views/harvests/_form.html.haml
T
Brenda WallaceandClaude Sonnet 5 92f3f0cc36 Convert Bootstrap 3 horizontal forms to Bootstrap 5
The label-beside-input forms (label col-md-2, input col-md-8) relied on
form-horizontal and form-group acting as a row. Each field wrapper is now a real
.row.mb-3, labels are col-form-label, help text is form-text, and the leftover
form-horizontal and form-actions classes, which do nothing in Bootstrap 5, are
dropped.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-20 18:03:36 +12:00

69 lines
2.9 KiB
Plaintext

.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2
= bootstrap_form_for(@harvest) do |f|
.card-header
- if content_for? :title
%h1.h2-responsive.text-center
= harvest_icon
%strong=yield :title
.card-body
- if @harvest.errors.any?
#error_explanation
%h2 #{pluralize(@harvest.errors.size, "error")} prohibited this harvest from being saved:"
%ul
- @harvest.errors.full_messages.each do |msg|
%li= msg
.row
.col-12
= f.label :crop, 'What did you harvest?', class: 'required'
- if @planting
= link_to @planting.crop.name, planting_path(@planting)
from
= link_to @planting.garden.name, garden_path(@planting.garden)
= f.hidden_field :planting_id, value: @planting.id
- else
= auto_suggest @harvest, :crop, class: 'form-control', default: @crop
- unless @planting
%span.form-text.col-md-8
Can't find what you're looking for?
= link_to "Request new crops.", new_crop_path
.col-md-4
= f.date_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_fs(:ymd) : '', label: 'When?'
.col-12
= f.form_group :plant_part_id, label: { text: "Harvested Plant Part" } do
.row
- PlantPart.all.order(:name).pluck(:id, :name).each do |id, name|
.col-4.col-md-3= f.radio_button :plant_part_id, id, label: name, checked: (id == @harvest.plant_part_id)
-# Some browsers (eg Firefox for Android) assume "number" means
-# "integer" unless you specify step="any":
-# http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/
.row
.col-md-4
= f.number_field :quantity, class: 'input-small form-control', step: 'any', label: 'How many?', min: 1
.col-md-8
= f.select(:unit, Harvest::UNITS_VALUES, { include_blank: false }, class: 'input-medium form-control')
.row
.col-md-4
= f.number_field :weight_quantity, class: 'input-small form-control', step: 'any', label: 'Weighing (in total)'
.col-md-8
= f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, { include_blank: false }, class: 'form-control')
= f.text_area :description, rows: 6, label: 'Notes'
- if @planting.present?
.row
.col-md-12
= f.range_field :overall_rating, min: 1, max: 5, value: @planting.overall_rating, include_blank: 'Leave blank', label: 'Overall Rating - Planting', list: "rating-list", title: "How well is the planting going?"
%datalist{"id": "rating-list"}
%option{"value": "1"} Poor
%option{"value": "2"}
%option{"value": "3"}
%option{"value": "4"}
%option{"value": "5"} Great
.card-footer
.text-end= f.submit 'Save'