Sha256: 5134112ebe4d08c6f8052e2550dd0a90de91b13ffa2e7daddf57300cfac12c42

Contents?: true

Size: 776 Bytes

Versions: 2

Compression:

Stored size: 776 Bytes

Contents

module FormGroups
  class FieldTag < ActionView::Helpers::Tags::Base
    def initialize object_name, method, object, template, form, options
      super object_name, method, template, options.merge(object: object)

      @builder = FieldBuilder.new object_name, method, object, form, options
    end

    def render &block
      html_options = @options.delete(:html) || {}

      classes = (html_options[:class] || '').split(' ')
      classes << FormGroups.field_class
      classes << FormGroups.field_error_class if object.errors.has_key?(@method_name.to_sym)

      html_options[:class] = classes

      output =  @template_object.tag(:div, html_options, true)
      output << @template_object.capture(@builder, &block)
      output.safe_concat '</div>'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
formgroups-rails-0.0.4 lib/form_groups/field_tag.rb
formgroups-rails-0.0.3 lib/form_groups/field_tag.rb