3
* Copyright(c) 2006-2010 Ext JS, Inc.
5
* http://www.extjs.com/license
8
* @class Ext.form.Radio
9
* @extends Ext.form.Checkbox
10
* Single radio field. Same as Checkbox, but provided as a convenience for automatically setting the input type.
11
* Radio grouping is handled automatically by the browser if you give each radio in a group the same name.
14
* @param {Object} config Configuration options
17
Ext.form.Radio = Ext.extend(Ext.form.Checkbox, {
21
* Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
24
markInvalid : Ext.emptyFn,
26
* Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
29
clearInvalid : Ext.emptyFn,
32
* If this radio is part of a group, it will return the selected value
35
getGroupValue : function(){
36
var p = this.el.up('form') || Ext.getBody();
37
var c = p.child('input[name='+this.el.dom.name+']:checked', true);
38
return c ? c.value : null;
43
if(this.el.dom.checked != this.checked){
44
var els = this.getCheckEl().select('input[name=' + this.el.dom.name + ']');
45
els.each(function(el){
46
if(el.dom.id == this.id){
49
Ext.getCmp(el.dom.id).setValue(false);
56
* Sets either the checked/unchecked status of this Radio, or, if a string value
57
* is passed, checks a sibling Radio of the same name whose value is the value specified.
58
* @param value {String/Boolean} Checked value, or the value of the sibling radio button to check.
59
* @return {Ext.form.Field} this
61
setValue : function(v){
62
if (typeof v == 'boolean') {
63
Ext.form.Radio.superclass.setValue.call(this, v);
64
} else if (this.rendered) {
65
var r = this.getCheckEl().child('input[name=' + this.el.dom.name + '][value=' + v + ']', true);
67
Ext.getCmp(r.id).setValue(true);
74
getCheckEl: function(){
76
return this.el.up('.x-form-radio-group')
78
return this.el.up('form') || Ext.getBody();
81
Ext.reg('radio', Ext.form.Radio);