Class: AdminAssistant::BelongsToColumn::FormView

Inherits:
View show all
Includes:
Column::FormViewMethods
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::FormViewMethods

#after_html, #description, #field_id, #html, #html_from_helper_method, #render_from_custom_template, #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

#default_html(form) ⇒ Object


128
129
130
131
132
133
134
135
136
# File 'lib/admin_assistant/belongs_to_column.rb', line 128

def default_html(form)
  if associated_class.count > 15
    render_autocompleter form
  else
    form.select(
      association_foreign_key, options_for_select, @select_options
    )
  end
end

#errors(record) ⇒ Object


138
139
140
# File 'lib/admin_assistant/belongs_to_column.rb', line 138

def errors(record)
  record.errors[@column.association_foreign_key]
end

#render_autocompleter(form) ⇒ Object


142
143
144
145
146
147
148
149
150
151
152
# File 'lib/admin_assistant/belongs_to_column.rb', line 142

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 => @select_options
    }
  )
end