Sha256: ba62f6ac8af46006a9ce85d44e5835ee1b6e19c7aee0727312f8f7246b9e04a8

Contents?: true

Size: 673 Bytes

Versions: 1

Compression:

Stored size: 673 Bytes

Contents

module FormGroups
  module GroupBuilder
    extend ActiveSupport::Concern

    included do
      def field method, options = {}, &block
        raise ArgumentError, "Missing block" unless block_given?

        FieldTag.new(object_name, method, object, @template, self, options).render(&block)
      end

      def id method
          @sanitized_id ||= object_name.to_s.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
      end

      def value method
        object[method]
      end

      private
        def objectify options
          options.merge(object: object)
        end
    end
  end
end

ActionView::Helpers::FormBuilder.send :include, FormGroups::GroupBuilder

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
formgroups-rails-0.0.4 lib/form_groups/group_builder.rb