diff --git a/app/form_builders/tailwind_form_builder.rb b/app/form_builders/tailwind_form_builder.rb index 4872347d..c2606456 100644 --- a/app/form_builders/tailwind_form_builder.rb +++ b/app/form_builders/tailwind_form_builder.rb @@ -58,6 +58,13 @@ def currency_field(object_method, options = {}) labels + field_wrapper end + def labels(object_method, label_options = {}, field_options = {}) + label = tailwind_label(object_method, label_options, field_options) + error_label = error_label(object_method, field_options) + + @template.content_tag('div', label + error_label, { class: 'flex flex-col items-start' }) + end + private def text_like_field(field_method, object_method, options = {}) @@ -75,13 +82,6 @@ def text_like_field(field_method, object_method, options = {}) labels + field end - def labels(object_method, label_options, field_options) - label = tailwind_label(object_method, label_options, field_options) - error_label = error_label(object_method, field_options) - - @template.content_tag('div', label + error_label, { class: 'flex flex-col items-start' }) - end - def tailwind_label(object_method, label_options, field_options) text, label_opts = if label_options.present? [label_options[:text], label_options.except(:text)] diff --git a/app/views/albums/_form.html.erb b/app/views/albums/_form.html.erb index 0434859c..bc7563a0 100644 --- a/app/views/albums/_form.html.erb +++ b/app/views/albums/_form.html.erb @@ -4,7 +4,7 @@ <%= form.currency_field :price, symbol: '£', class: 'w-full mb-2' %> <%= form.text_area :about, rows: 10, class: 'w-full mb-3' %> <%= form.text_area :credits, rows: 10, class: 'w-full mb-3' %> - <%= form.label :cover %> + <%= form.labels :cover %> <%= form.file_field :cover, accept: 'image/jpeg,image/png', class: 'block border border-slate-200 mb-3 file:mr-3 file:px-3 file:py-3 w-full file:border-0 file:bg-amber-600 hover:file:bg-amber-500 file:text-white' %>