Class: Clot::CheckBox

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

Constant Summary

Constants inherited from ClotTag

Clot::ClotTag::Syntax

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



128
129
130
131
132
133
# File 'lib/clot/model_form_tags.rb', line 128

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



117
118
119
120
121
122
123
124
125
126
# File 'lib/clot/model_form_tags.rb', line 117

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