Sha256: 98c23f9cc7388812b16745450cfcc996d26585cf3abffedc44725e03af0310b7

Contents?: true

Size: 830 Bytes

Versions: 1

Compression:

Stored size: 830 Bytes

Contents

module Motr
  module Forms
    ##
    # 
    # # Custom form helpers and modifications
    #
    module Helpers
      
      ##
      # 
      # Cusomizes the default form_for helper to add additional functionality
      # (see ActionView::Helpers::FormHelper for more information)
      # 
      # @option options [Boolean] :validate Adds a data-validatable attribute to the form for javascript hooks
      # 
      def motr_form(record, options = {}, &block)
       
        raise ArgumentError, "Missing block" unless block_given?
        
        options.reverse_merge!(:builder => Motr::Forms.default_builder)
        options[:html] ||= {}
        options[:html].merge!('data-validatable' => true) if options.delete(:validate)
        form_for(record, options, &block)
                
      end
      
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
motr-0.0.1 lib/motr/forms/helpers.rb