Class: Clot::CollectionSelect

Inherits:
ClotTag
  • Object
show all
Defined in:
lib/clot/model_form_tags.rb

Constant Summary

Constants inherited from ClotTag

Clot::ClotTag::Syntax

Instance Method Summary collapse

Methods inherited from ClotTag

#initialize

Methods included from TagHelper

#resolve_value, #split_params

Methods included from AttributeSetter

#personal_attributes, #set_attributes, #set_primary_attributes

Constructor Details

This class inherits a constructor from Clot::ClotTag

Instance Method Details

#render(context) ⇒ Object

usage: collection_select “order” method:“country_id”, collection:available_countries, value_method:‘id’, text_method:‘name’, html_options:“{class:‘large-field’” %}



98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/clot/model_form_tags.rb', line 98

def render(context)
  super(context)

  # collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {})
  method = @attributes['method']
  collection = @attributes['collection']
  value_method = @attributes['value_method']
  text_method = @attributes['text_method']
  @attributes.has_key?('options') ? options = @attributes['options'] : options = {}
  @attributes.has_key?('html_options') ? html_options = @attributes['html_options'] : html_options = {}


  context.registers[:action_view].collection_select(@form_object, method, collection, value_method, text_method, options, html_options)
end