radio
用途
单选按钮的帮助标签.
示例
<g:radio name="myGroup" value="1"/>
<g:radio name="myGroup" value="2" checked="true"/>
相当于:
<input type="radio" name="myGroup" value="1" />
<input type="radio" name="myGroup" checked="checked" value="2" />
描述
属性
value
(必需) - radio button 的值
name
(必需) - radio button 的名称
checked
(可选) - 是否选中,true为选中,false 为不选中.
Source
Show Source
def radio = {attrs ->
def value = attrs.remove('value')
attrs.id = attrs.id ? attrs.id : attrs.name
def name = attrs.remove('name')
def disabled = attrs.remove('disabled')
if (disabled && Boolean.valueOf(disabled)) {
attrs.disabled = 'disabled'
}
def checked = (attrs.remove('checked') ? true : false)
out << '<input type="radio" '
out << "name=\"${name}\" "
if (checked) {
out << 'checked="checked" '
}
out << "value=\"${value.toString().encodeAsHTML()}\" "
// process remaining attributes
outputAttributes(attrs) // close the tag, with no body
out << ' />'
}