Class: Clot::CheckBoxTag

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

Instance Method Summary collapse

Methods inherited from ClotTag

#initialize, #render

Methods included from TagHelper

#resolve_value, #split_params

Methods included from AttributeSetter

#set_attributes

Constructor Details

This class inherits a constructor from Clot::ClotTag

Instance Method Details

#personal_attributes(name, value) ⇒ Object



203
204
205
206
207
208
209
210
211
212
213
# File 'lib/clot/no_model_form_tags.rb', line 203

def personal_attributes(name,value)
  case name
    when 'collection' then
      @checkbox_collection = value
    when 'member' then
      @checkbox_member = value
      if (! @checkbox_collection.nil?) && @checkbox_collection.include?(@checkbox_member)
        @checked_value = %{checked="checked" }
      end
  end
end

#render_stringObject



226
227
228
229
# File 'lib/clot/no_model_form_tags.rb', line 226

def render_string
  @value_string ||= 1
  %{<input #{@disabled_string}#{@class_string}#{@checked_value}id="#{@id_string}" name="#{@name_string}" type="checkbox" value="#{@value_string}" />}
end

#set_primary_attributes(context) ⇒ Object



216
217
218
219
220
221
222
223
224
# File 'lib/clot/no_model_form_tags.rb', line 216

def set_primary_attributes(context)
  super context
  if @params[0] && ! @params[0].match(/:/)
    checked = resolve_value @params.shift, context
    if checked
      @checked_value = %{checked="checked" }
    end
  end
end