Backback arrow icon

railsのsimple formでtailwindのエラーを適用


SimpleForm.setup do |config|
  # Wrappers are used by the form builder to generate a
  # complete input. You can remove any component from the
  # wrapper, change the order or even add your own to the
  # stack. The options given below are used to wrap the
  # whole input.
  config.wrappers :default, class: :input,
    hint_class: :field_with_hint, error_class: '', valid_class: '' do |b|

    b.use :label, class: "block text-sm font-medium text-gray-700"
    b.use :input,
          class: 'appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm',
          error_class: 'block w-full pr-10 border-red-300 text-red-900 placeholder-red-300 focus:outline-none focus:ring-red-500 focus:border-red-500 sm:text-sm rounded-md'
    b.use :full_error, wrap_with: { tag: 'p', class: 'mt-2 text-sm text-red-600' }
    b.use :hint,  wrap_with: { tag: :p, class: "mt-2 text-sm text-gray-500" }