Class: CML::Tags::Radio
Constant Summary
collapse
- BareTemplate =
<<-HTML.freeze
<input name="{{name}}" type="radio" value="{{value}}" class="{{classes}}" {{checked}}/>
HTML
- Template =
<<-HTML.freeze
<div class="cml_row" {{title}}><label class="{{gold_class}}">#{BareTemplate} {{label}}</label></div>
HTML
CML::TagLogic::And, CML::TagLogic::AndPhraseExp, CML::TagLogic::CombinatorDefault, CML::TagLogic::CombinatorDict, CML::TagLogic::CombinatorExp, CML::TagLogic::GroupExp, CML::TagLogic::Or, CML::TagLogic::OrCombinatorExp, CML::TagLogic::PrecedenceRegexp, CML::TagLogic::TokenExp, CML::TagLogic::TokenRegexp
Instance Attribute Summary
Attributes inherited from CML::Tag
#attrs, #cml, #opts, #tag
#errors, #has_grouped_logic, #has_liquid_logic, #logic_tree
Instance Method Summary
collapse
Methods inherited from CML::Tag
#cacheable?, #children, #classes, #convert, #ensure_resolved, #gold=, #gold?, #gold_class, #gold_reason, #initialize, #instructions, #iterating?, #label, #legend, memoize, #multi_type, #name, #parent_multiples, #prefix, #preloaded_data, #raw_label, #to_html, #to_liquid, #to_s, #validations, #validators, #wrapper_classes
#dependencies_on_fields, #dependencies_through_cml_group, #depends_on_fields, #describe_logic_token, #detect_grouped_logic, #detect_liquid_logic, #each_logic_token_in, #expand_logic, #expand_parsed_expression, #keep_merge!, #only_if, parse_expression, resolve_combinator
Constructor Details
This class inherits a constructor from CML::Tag
Instance Method Details
#checked ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/cml/tags/radio.rb', line 37
def checked
manipulated = !@opts[:missed].nil?
if preload = preloaded_data
manipulated = true
if Array(preload).map{|x| x.to_s.downcase }.include?(value.to_s.downcase)
return "checked=\"checked\""
end
end
!manipulated && @attrs["checked"] ? "checked=\"checked\"" : ""
end
|
#data ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/cml/tags/radio.rb', line 48
def data
super.merge({
"checked" => checked,
"label" => @attrs["label"].to_s,
"title" => title_attribute
})
end
|
#finite_value? ⇒ Boolean
21
22
23
|
# File 'lib/cml/tags/radio.rb', line 21
def finite_value?
true
end
|
#grouped? ⇒ Boolean
Radios should always be grouped, but for consistency with checkboxes, we check
13
14
15
|
# File 'lib/cml/tags/radio.rb', line 13
def grouped?
@opts[:bare] || (@cml.parent && ["radios","ratings"].include?(@cml.parent.name))
end
|
#in_logic_graph? ⇒ Boolean
17
18
19
|
# File 'lib/cml/tags/radio.rb', line 17
def in_logic_graph?
!grouped?
end
|
#validate? ⇒ Boolean
33
34
35
|
# File 'lib/cml/tags/radio.rb', line 33
def validate?
@attrs["duplicate"] ? false : true
end
|
#value ⇒ Object
29
30
31
|
# File 'lib/cml/tags/radio.rb', line 29
def value
ensure_resolved((@attrs["value"] || @attrs["label"]).to_s)
end
|
#wrapper(parsed) ⇒ Object
25
26
27
|
# File 'lib/cml/tags/radio.rb', line 25
def wrapper(parsed)
grouped? ? parsed : super
end
|