% %i[label field error help after_help].each do |key| if (content = content_for(key).presence) flush_content_for key partial.section key, content end end %> <% form ||= current_fields_form # returns a struct with `label`, `placeholder`, and `help` methods. labels = labels_for(form, method) options ||= {} options[:id] ||= form.field_id(method) # options[:disabled] ||= !field_editable?(form.object, method) if user_signed_in? options[:placeholder] ||= labels.placeholder if labels.placeholder other_options ||= {} other_options[:help] = [other_options[:help], labels.help].compact.join(" ") errors = [method, method.to_s.delete_suffix("_id").to_sym].uniq.map { |attribute| form.object.errors.full_messages_for(attribute) }.flatten has_errors = errors.any? || partial.error? || other_options[:error].present? options[:class] = "#{options[:class]} block w-full rounded-md shadow-sm font-light" options[:class] += " text-base md:text-sm" # default to 16px on mobile to prevent zooming options[:class] += if has_errors " pr-10 border-red text-red-700 placeholder-red focus:outline-none focus:ring-red focus:border-red" else " focus:ring-blue focus:border-blue border-slate-300" end %>
<%= errors.map { |error| error + ". " }.join %> <%= partial.error %> <%= other_options[:error]&.html_safe %>
<% end %> <% # any help text. %> <% if partial.help? || other_options[:help] || partial.after_help? %><%= partial.help %> <%= other_options[:help]&.html_safe %> <%= partial.after_help %>
<% end %> <% if other_options[:icon] %> <% end %>