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' %>
@@ -28,9 +28,9 @@ <%= f.text_field :title, class: 'w-full mb-6', required: true %> <% if f.object.original.attached? %> - <%= f.label :original, "File (#{f.object.original.filename})", class: 'text-slate-600 mb-1 md:mb-0 pr-4' %> + <%= f.labels :original, text: "File (#{f.object.original.filename})" %> <% else %> - <%= f.label :original, "File", class: 'text-slate-600 mb-1 md:mb-0 pr-4' %> + <%= f.labels :original, text: "File" %> <% end %> <%= f.file_field :original, accept: 'audio/x-wav', direct_upload: true, class: 'block border border-slate-200 mb-2 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' %>