Sha256: 243775e807bb1660880b65038c11f4740a4b080fa45ef274f5047e2550b05eaf

Contents?: true

Size: 934 Bytes

Versions: 3

Compression:

Stored size: 934 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') +
          hidden_field(:captcha_key, {:value => options[:field_value]})
        end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
glebtv-simple_captcha-0.8.0 lib/simple_captcha/hooks/form_builder.rb
glebtv-simple_captcha-0.7.0 lib/simple_captcha/hooks/form_builder.rb
glebtv-simple_captcha-0.6.7 lib/simple_captcha/hooks/form_builder.rb