Class: Raw::CheckboxControl

Inherits:
AttributeControl show all
Defined in:
lib/raw/control/attribute/checkbox.rb

Overview

A Control used to edit boolean attributes.

Instance Attribute Summary

Attributes inherited from AttributeControl

#anno, #attribute, #value

Attributes included from ElementMixin

#_children, #_parent, #_text, #_view, #id

Instance Method Summary collapse

Methods inherited from AttributeControl

#initialize

Methods included from XhtmlHelper

#date_select, #datetime_select, #hidden, #href_of, #js_popup, #link_to, #objects_to_options, #onclick_popup, #options, #popup, #submit, #time_select

Methods included from ElementMixin

#add_child, #close, #content, #include, #initialize, #open, #render_children

Constructor Details

This class inherits a constructor from Raw::AttributeControl

Instance Method Details

#emit_labelObject



17
18
19
20
21
# File 'lib/raw/control/attribute/checkbox.rb', line 17

def emit_label
  return '' if @options[:no_label]
  title = @anno[:title] || @options[:label] || @attribute.to_s.humanize
  %{<label for="#{@attribute}" style="display: inline">#{title}</label>}
end

#renderObject



10
11
12
13
14
15
# File 'lib/raw/control/attribute/checkbox.rb', line 10

def render
  checked = @value == true ? ' checked="checked"' : ''
  %{
  <input type="checkbox" id="#{control_id}" name="#{@attribute}" #{emit_style}#{checked}#{emit_disabled} />&nbsp;#{emit_label}
  }
end