class HtmlGrid::Label
Public Class Methods
new(component, session, label_key = nil)
click to toggle source
Calls superclass method
# File lib/htmlgrid/label.rb, line 48 def initialize(component, session, label_key = nil) @component = component @attributes = {} @session = session @lookandfeel = session.lookandfeel @label_key = label_key if @component.respond_to? :name @attributes["for"] = @component.name.to_s @label_key ||= @component.name end if @component.respond_to?(:data_origin) \ && (origin = @component.data_origin) @attributes.store("title", origin.to_s) end if @session.error(@label_key) \ || (@component.respond_to?(:name) && @session.error(@component.name)) @attributes["class"] = "error" end if @component.respond_to?(:attributes) \ && (id = @component.attributes["id"]) @attributes.store("id", "label_#{id}") end super(component) end
Public Instance Methods
each() { |self| ... }
click to toggle source
# File lib/htmlgrid/label.rb, line 73 def each yield self if @component.respond_to?(:label?) && @component.label? yield @component end
to_html(context)
click to toggle source
# File lib/htmlgrid/label.rb, line 78 def to_html(context) key = @label_key label = @lookandfeel.lookup(key) if !label && @component.respond_to?(:name) key = @component.name label = @lookandfeel.lookup(key) end state = @session.state if label && state.respond_to?(:mandatory?) && state.mandatory?(key) label += "*" end if label context.label(@attributes) { label } end end