Skip to content

Commit

Permalink
refactor artist form
Browse files Browse the repository at this point in the history
  • Loading branch information
BlazingRockStorm committed Aug 19, 2024
1 parent 1099a08 commit d40d13c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 38 deletions.
18 changes: 18 additions & 0 deletions app/views/admin/artists/_form.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
= form_with model: [:admin, @artist], local: true do |form|
- if @artist.errors.any?
.alert.alert-danger
h2 = "#{pluralize(@artist.errors.count, "error")} prohibited this artist from being saved:"
ul
- @artist.errors.each do |error|
li = error.full_message

.mb-3
= form.label :name, class: 'form-label'
= form.text_field :name, class: 'form-control'

.mb-3
= form.label :biography, class: 'form-label'
= form.text_area :biography, class: 'form-control', rows: 20

div
= form.submit class: 'btn btn-primary'
20 changes: 1 addition & 19 deletions app/views/admin/artists/edit.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,7 @@
main.col-md-9.col-lg-10.mt-2.mb-2
h1 Editing artist

= form_with scope: :artist, url: admin_artist_path(@artist), method: :patch do |form|
- if @artist.errors.any?
.alert.alert-danger
h2 = "#{pluralize(@artist.errors.count, "error")} prohibited this artist from being saved:"
ul
- @artist.errors.each do |error|
li = error.full_message

.mb-3
= form.label :name, class: 'form-label'
= form.text_field :name, class: 'form-control'

.mb-3
= form.label :biography, class: 'form-label'
= form.text_area :biography, class: 'form-control', rows: 20

div
= form.submit 'Save artist', class: 'btn btn-primary'

== render 'form', artist: @artist

br

Expand Down
20 changes: 1 addition & 19 deletions app/views/admin/artists/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,7 @@
main.col-md-9.col-lg-10.mt-2.mb-2
h1 New artist

= form_with scope: :artist, url: admin_artists_path do |form|
- if @artist.errors.any?
.alert.alert-danger
h2 = "#{pluralize(@artist.errors.count, "error")} prohibited this artist from being saved:"
ul
- @artist.errors.each do |error|
li = error.full_message

.mb-3
= form.label :name, class: 'form-label'
= form.text_field :name, class: 'form-control'

.mb-3
= form.label :biography, class: 'form-label'
= form.text_area :biography, class: 'form-control', rows: 20

div
= form.submit 'Create Artist', class: 'btn btn-primary'

== render 'form', artist: @artist

br

Expand Down

0 comments on commit d40d13c

Please sign in to comment.