Sha256: 85fe30e11a0d72086879b6a2f0a5bb577954f8efa08441528f8086994363120d

Contents?: true

Size: 961 Bytes

Versions: 1

Compression:

Stored size: 961 Bytes

Contents

module SimpleCaptcha
  module FormBuilder
    def self.included(base)
      base.send(:include, SimpleCaptcha::ViewHelper)
      base.send(:include, SimpleCaptcha::FormBuilder::ClassMethods)
      
      base.delegate :render, :session, :to => :template
    end
    
    module ClassMethods
      # Example:
		  # <% form_for :post, :url => posts_path do |form| %>
		  #   ...
		  #   <%= form.simple_captcha :label => "Enter numbers.." %>
		  # <% end %>
		  #
		  def simple_captcha(options = {})
      	options.update :object => @object_name
      	show_simple_captcha(objectify_options(options))
      end
      
      private
        
        def template
          @template
        end
        
        def simple_captcha_field(options={})
          text_field(:captcha, { :value => '', :autocomplete => 'off' }.merge(options[:field_options] || {})) +
          hidden_field(:captcha_key, {:value => options[:field_value]})
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nahaylo-simple_captcha-0.2.0 lib/simple_captcha/form_builder.rb