Class: AdminAssistant::BelongsToColumn::SearchView

Inherits:
View show all
Includes:
Column::SearchViewMethods
Defined in:
lib/admin_assistant/belongs_to_column.rb

Instance Attribute Summary

Attributes inherited from Column::View

#sort_order

Instance Method Summary collapse

Methods included from Column::SearchViewMethods

#set_instance_variables_from_options

Methods inherited from View

#assoc_value, #associated_class, #association_foreign_key, #initialize, #options_for_select, #value

Methods inherited from Column::View

#check_box_and_hidden_tags, #controller, #custom_template_file_path, #file_option_for_custom_template_render, #initialize, #label, #name, #paperclip?, #sort_possible?, #string, #value

Constructor Details

This class inherits a constructor from AdminAssistant::BelongsToColumn::View

Instance Method Details

#html(form) ⇒ Object



162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/admin_assistant/belongs_to_column.rb', line 162

def html(form)
  input = if @column.match_text_fields_in_search
    form.text_field(name)
  elsif associated_class.count > 15
    render_autocompleter form
  else
    form.select(
      association_foreign_key, options_for_select,
      :include_blank => true
    )
  end
  "<p><label>#{label}</label> <br/>#{input}</p>"
end

#render_autocompleter(form) ⇒ Object



176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/admin_assistant/belongs_to_column.rb', line 176

def render_autocompleter(form)
  @action_view.send(
    :render,
    :file => AdminAssistant.template_file('_token_input'),
    :use_full_path => false,
    :locals => {
      :form => form, :column => @column,
      :select_options => {:include_blank => true},
      :palette_clones_input_width => false
    }
  )
end