Class: Clot::CheckBoxTag

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

Constant Summary

Constants inherited from ClotTag

Clot::ClotTag::Syntax

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



210
211
212
213
214
215
216
217
218
219
220
# File 'lib/clot/no_model_form_tags.rb', line 210

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



233
234
235
236
# File 'lib/clot/no_model_form_tags.rb', line 233

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



223
224
225
226
227
228
229
230
231
# File 'lib/clot/no_model_form_tags.rb', line 223

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