Class: Clot::CheckBox

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

Instance Method Summary collapse

Methods included from ModelTag

#render

Methods inherited from ClotTag

#initialize, #render

Methods included from TagHelper

#resolve_value, #split_params

Methods included from AttributeSetter

#personal_attributes, #set_attributes

Constructor Details

This class inherits a constructor from Clot::ClotTag

Instance Method Details

#render_stringObject



197
198
199
200
201
202
# File 'lib/clot/model_form_tags.rb', line 197

def render_string
  if @item[@attribute_name.to_sym]
    @checked_value = %{checked="checked" }
  end
  %{<input name="#{@name_string}" type="hidden" value="#{@false_val}" />} + %{<input #{@disabled_string}#{@class_string}#{@checked_value}id="#{@id_string}" name="#{@name_string}" type="checkbox" value="#{@true_val}" />}
end

#set_primary_attributes(context) ⇒ Object



186
187
188
189
190
191
192
193
194
195
# File 'lib/clot/model_form_tags.rb', line 186

def set_primary_attributes(context)
  super(context)
  if @params.length > 1 && ! @params[0].match(/:/) && ! @params[1].match(/:/)
    @true_val = resolve_value(@params.shift,context)
    @false_val = resolve_value(@params.shift,context)
  else
    @true_val = 1
    @false_val = 0
  end
end