mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-11 17:24:50 -04:00
Tidying up forms
This commit is contained in:
@@ -41,7 +41,7 @@ class PlantingsController < ApplicationController
|
||||
end
|
||||
|
||||
def new
|
||||
@planting = Planting.new(planted_at: Time.zone.today)
|
||||
@planting = Planting.new(planted_at: Time.zone.today, owner: current_member )
|
||||
@seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id]
|
||||
|
||||
# using find_by_id here because it returns nil, unlike find
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2
|
||||
.card-body
|
||||
= bootstrap_form_for(@garden) do |f|
|
||||
- if content_for? :title
|
||||
%h1.h2-responsive.text-center
|
||||
%strong=yield :title
|
||||
= required_field_help_text
|
||||
|
||||
= form_for(@garden, html: { class: "form-horizontal", role: "form" }) do |f|
|
||||
.card-header
|
||||
%h1.h2-responsive.text-center
|
||||
%strong=yield :title
|
||||
.card-body
|
||||
= required_field_help_text
|
||||
- if @garden.errors.any?
|
||||
#error_explanation
|
||||
%h2
|
||||
@@ -15,55 +15,27 @@
|
||||
- @garden.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.form-group.required
|
||||
= f.label :name, class: 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.text_field :name, class: 'form-control', maxlength: 255, required: "required"
|
||||
= f.text_field :name, maxlength: 255, required: "required"
|
||||
= f.text_area :description, rows: 6
|
||||
|
||||
.form-group
|
||||
= f.label :description, class: 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.text_area :description, rows: 6, class: 'form-control'
|
||||
= render partial: 'shared/form_optional'
|
||||
= f.text_field :location,
|
||||
value: @garden.location || current_member.location,
|
||||
class: 'form-control', maxlength: 255
|
||||
= render partial: 'shared/form_optional'
|
||||
%span.help-block
|
||||
= t('.location_helper')
|
||||
- if current_member.location.blank?
|
||||
= link_to "Set your location now.", edit_member_registration_path
|
||||
- else
|
||||
= link_to "Change your location.", edit_member_registration_path
|
||||
.row
|
||||
.col-3= f.number_field :area, class: 'input-small'
|
||||
.col-3= f.select(:area_unit, Garden::AREA_UNITS_VALUES, { include_blank: false })
|
||||
.col-6= f.select(:garden_type_id, GardenType.all.order(:name).pluck(:name, :id),
|
||||
selected: @garden.garden_type_id)
|
||||
|
||||
.form-group
|
||||
= f.label :location, class: 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.text_field :location,
|
||||
value: @garden.location || current_member.location,
|
||||
class: 'form-control', maxlength: 255
|
||||
= render partial: 'shared/form_optional'
|
||||
%span.help-block
|
||||
= t('.location_helper')
|
||||
- if current_member.location.blank?
|
||||
= link_to "Set your location now.", edit_member_registration_path
|
||||
- else
|
||||
= link_to "Change your location.", edit_member_registration_path
|
||||
|
||||
.form-group
|
||||
= f.label :area, class: 'control-label col-md-2'
|
||||
.col-md-2
|
||||
= f.number_field :area, class: 'input-small form-control'
|
||||
= render partial: 'shared/form_optional'
|
||||
.col-md-2
|
||||
= f.select(:area_unit, Garden::AREA_UNITS_VALUES, { include_blank: false }, class: 'form-control')
|
||||
|
||||
.form-group
|
||||
= f.label :garden_type, class: 'control-label col-md-2'
|
||||
.col-md-2
|
||||
= collection_select(:garden, :garden_type_id,
|
||||
GardenType.all.order(:name),
|
||||
:id, :name,
|
||||
selected: @garden.garden_type_id,
|
||||
class: 'form-control')
|
||||
|
||||
.form-group
|
||||
= f.label :active, 'Active? ', class: 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.check_box :active
|
||||
You can mark a garden as inactive if you no longer use it. Note:
|
||||
this will mark all plantings in the garden as "finished".
|
||||
|
||||
.form-group
|
||||
.form-actions.col-md-offset-2.col-md-8
|
||||
= f.submit 'Save Garden', class: 'btn btn-primary'
|
||||
= f.check_box :active, label: 'Active?'
|
||||
You can mark a garden as inactive if you no longer use it. Note:
|
||||
this will mark all plantings in the garden as "finished".
|
||||
.card-footer
|
||||
.text-right= f.submit 'Save Garden'
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2
|
||||
.card-header
|
||||
- if content_for? :title
|
||||
%h1.h2-responsive.text-center
|
||||
%strong=yield :title
|
||||
.card-body
|
||||
= required_field_help_text
|
||||
|
||||
= bootstrap_form_for(@harvest) do |f|
|
||||
= bootstrap_form_for(@harvest) do |f|
|
||||
.card-header
|
||||
- if content_for? :title
|
||||
%h1.h2-responsive.text-center
|
||||
= harvest_icon
|
||||
%strong=yield :title
|
||||
.card-body
|
||||
= required_field_help_text
|
||||
- if @harvest.errors.any?
|
||||
#error_explanation
|
||||
%h2 #{pluralize(@harvest.errors.size, "error")} prohibited this harvest from being saved:"
|
||||
@@ -50,6 +51,6 @@
|
||||
= f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, { include_blank: false }, class: 'form-control')
|
||||
= f.text_area :description, rows: 6, label: 'Notes'
|
||||
|
||||
|
||||
.card-footer
|
||||
.text-right= f.submit 'Save'
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@
|
||||
.row
|
||||
.col-md-8
|
||||
= f.collection_radio_buttons(:garden_id,
|
||||
@planting.owner.gardens.active.order_by_name, :id, :name, required: true,
|
||||
@planting.owner.gardens.active.order_by_name,
|
||||
:id, :name, required: true,
|
||||
label: 'Where did you plant it?')
|
||||
= link_to "Add a garden.", new_garden_path
|
||||
.col-md-4
|
||||
= f.text_field :planted_at,
|
||||
value: @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '',
|
||||
class: 'add-datepicker', label: 'When?'
|
||||
-# = render partial: 'shared/form_optional'
|
||||
|
||||
.row
|
||||
.col-md-4= f.select(:planted_from, Planting::PLANTED_FROM_VALUES, { include_blank: '' }, label: 'Planted from')
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2
|
||||
.card-body
|
||||
- if content_for? :title
|
||||
%h1.h2-responsive.text-center
|
||||
%strong=yield :title
|
||||
= form_for(@post, html: { role: "form" }) do |f|
|
||||
= bootstrap_form_for(@post) do |f|
|
||||
.card-body
|
||||
- if content_for? :title
|
||||
%h1.h2-responsive.text-center
|
||||
%strong=yield :title
|
||||
- if @post.errors.any?
|
||||
#error_explanation
|
||||
%h2
|
||||
@@ -13,18 +13,14 @@
|
||||
- @post.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.form-group
|
||||
= label_tag :post, "Subject", class: 'control-label'
|
||||
= f.text_field :subject, class: 'form-control', autofocus: 'autofocus', maxlength: 255
|
||||
= f.text_field :subject, autofocus: 'autofocus', maxlength: 255
|
||||
|
||||
.form-group
|
||||
- if @post.forum || @forum
|
||||
= label_tag :body, "What's up?", class: 'control-label'
|
||||
- else
|
||||
= label_tag :body, "What's going on in your food garden?"
|
||||
= f.text_area :body, rows: 12, class: 'form-control'
|
||||
%span.help-block
|
||||
= render partial: "shared/markdown_help"
|
||||
- if @post.forum || @forum
|
||||
= label_tag :body, "What's up?"
|
||||
- else
|
||||
= label_tag :body, "What's going on in your food garden?"
|
||||
= f.text_area :body, rows: 12
|
||||
%span.help-block= render partial: "shared/markdown_help"
|
||||
|
||||
- if @post.forum || @forum
|
||||
- forum = @post.forum || @forum
|
||||
@@ -33,5 +29,5 @@
|
||||
= link_to forum.name, forum
|
||||
.field
|
||||
= f.hidden_field :forum_id, value: forum.id
|
||||
|
||||
= f.submit "Post", class: 'btn btn-primary'
|
||||
.card-footer
|
||||
.text-right= f.submit "Post", class: 'btn btn-primary'
|
||||
|
||||
Reference in New Issue
Block a user