Sha256: f8f48db27ad71089169f7e214868516be595d037c6abe07aae725c64b43b7149

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 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 << 'field'
      classes << 'field-errors' 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

1 entries across 1 versions & 1 rubygems

Version Path
formgroups-rails-0.0.2 lib/form_groups/field_tag.rb