Class: HCheckBoxTag

Inherits:
HGroupTag show all
Defined in:
lib/hwidgets/hcheckboxtag.rb

Instance Attribute Summary collapse

Attributes inherited from HGroupTag

#items, #values

Attributes inherited from HWidget

#tag

Instance Method Summary collapse

Methods inherited from HGroupTag

#setCarriageReturn, #setItems, #setItemsAndValues, #setSelected, #setValues

Methods inherited from HWidget

#_addJsSlot, #_set, #_setStyle, #addJsFunction, #appendChild, #appendChilds, #buildSignature, #closeTag, #connect, #copyConstructor, #get, #getChilds, #getElementBy, #getSystemProperty, #hotLog, #openTag, #replacePlaceholder, #reset, #set, #setChilds, #setCloseTag, #setClosedTag, #setEnablePlaceholder, #setInnerHTML, #setParent, #setPlaceholder, #setPlaceholders, #setProperties, #setSlots, #setStyle, #setStyles, #setSystemProperties, #setSystemProperty, #setTag, #storeSlots, #storeStyle, #strProperties, test, #unset, widgetSpace

Constructor Details

#initialize(name = nil, modelName = nil, placeholder = nil) ⇒ HCheckBoxTag

Returns a new instance of HCheckBoxTag.



9
10
11
12
# File 'lib/hwidgets/hcheckboxtag.rb', line 9

def initialize(name = nil, modelName = nil, placeholder = nil)
  super(name, modelName, placeholder)
  @checkBox = nil
end

Instance Attribute Details

#checkedObject

Returns the value of attribute checked.



7
8
9
# File 'lib/hwidgets/hcheckboxtag.rb', line 7

def checked
  @checked
end

Instance Method Details

#htmlObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/hwidgets/hcheckboxtag.rb', line 14

def html()
  for i in (0..@items.count - 1) do
    item = @items[i]
    value = @values[i]
    id = "#{@modelName}_#{@name}_#{value.downcase()}"
    name = "#{@modelName}[#{@name}][#{value}]"
    hiddenCheckBox = HInputTag.new(@name, @modelName, nil, nil, type = "hidden").set(name: name, value: "0")
    checkBox = HInputTag.new(@name, @modelName, value, nil, type = "checkbox") if (@checkBox == nil)
    checkBox.placeholder = item
    checkBox.set(checked: "") if (@selectedItem[value.to_s] == "1")
    checkBox.set(name: name, value: "1", id: id)
    checkBox.setReverse()
    self << checkBox << hiddenCheckBox
  end

  return super()

end