Sha256: 01aa19c92eb2ea3c1df852f83d7d456a647b120441b19f85b81e397b41229f43

Contents?: true

Size: 721 Bytes

Versions: 2

Compression:

Stored size: 721 Bytes

Contents

class Wallaby::FormBuilder < ActionView::Helpers::FormBuilder
  def error_class(field_name)
    'has-error' if has_error? field_name
  end

  def error_messages(field_name)
    errors = Array object.errors[ field_name ]
    return if errors.blank?

    content_tag :ul, class: 'text-danger' do
      errors.each do |message|
        concat content_tag :li, content_tag(:small, raw(message))
      end
    end
  end

  protected
  def method_missing(method, *args, &block)
    if @template.respond_to? method
      self.class.delegate method, to: :@template
      @template.public_send method, *args, &block
    else
      super
    end
  end

  def has_error?(field_name)
    object.errors[field_name].present?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wallaby-4.1.6 lib/forms/wallaby/form_builder.rb
wallaby-5.0.1 lib/forms/wallaby/form_builder.rb