Changeset 22

Show
Ignore:
Timestamp:
11/02/2006 06:41:24 PM (2 years ago)
Author:
matthew
Message:

Add a text_field_with_auto_complete helper, as a quick hack; currently
needs to be pointed to a different controller to provide the completion
data.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/auto-admin/lib/auto_admin_simple_theme.rb

    r15 r22  
    220220    private :field_value 
    221221 
     222    def object_helper(helper_name, field, options, *extra) 
     223      @template.send(helper_name, @object_name, field, options.merge( :object => @object ), *extra) 
     224    end 
     225    private :object_helper 
     226 
    222227    def inner_fields_for(inner_object_name, inner_object) 
    223228      @template.fields_for( "#{@object_name}_#{inner_object_name}", inner_object, @template, @options ) do |i| 
     
    251256      common_option_translations! options 
    252257      super 
     258    end 
     259    def text_field_with_auto_complete(field, options = {}) 
     260      common_option_translations! options 
     261      completion_options = options.delete(:completion) || {} 
     262      raise "AutoAdmin text_field_with_auto_complete requires explicit :completion => { :url => .. }" unless completion_options.key? :url 
     263      object_helper :text_field_with_auto_complete, field, options, completion_options 
    253264    end 
    254265    def text_field(field, options = {})