2 * Ext JS Library 2.2.1
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
10 * @class Ext.form.Radio
\r
11 * @extends Ext.form.Checkbox
\r
12 * Single radio field. Same as Checkbox, but provided as a convenience for automatically setting the input type.
\r
13 * Radio grouping is handled automatically by the browser if you give each radio in a group the same name.
\r
15 * Creates a new Radio
\r
16 * @param {Object} config Configuration options
\r
18 Ext.form.Radio = Ext.extend(Ext.form.Checkbox, {
\r
22 baseCls: 'x-form-radio',
\r
25 * If this radio is part of a group, it will return the selected value
\r
28 getGroupValue : function(){
\r
29 var c = this.getParent().child('input[name='+this.el.dom.name+']:checked', true);
\r
30 return c ? c.value : null;
\r
34 getParent : function(){
\r
35 return this.el.up('form') || Ext.getBody();
\r
39 toggleValue : function() {
\r
41 var els = this.getParent().select('input[name='+this.el.dom.name+']');
\r
42 els.each(function(el){
\r
43 if(el.dom.id == this.id){
\r
44 this.setValue(true);
\r
46 Ext.getCmp(el.dom.id).setValue(false);
\r
53 * Sets either the checked/unchecked status of this Radio, or, if a string value
\r
54 * is passed, checks a sibling Radio of the same name whose value is the value specified.
\r
55 * @param value {String/Boolean} Checked value, or the value of the sibling radio button to check.
\r
57 setValue : function(v){
\r
58 if(typeof v=='boolean') {
\r
59 Ext.form.Radio.superclass.setValue.call(this, v);
\r
61 var r = this.getParent().child('input[name='+this.el.dom.name+'][value='+v+']', true);
\r
62 if(r && !r.checked){
\r
63 Ext.getCmp(r.id).toggleValue();
\r
69 * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
\r
72 markInvalid : Ext.emptyFn,
\r
74 * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
\r
77 clearInvalid : Ext.emptyFn
\r
80 Ext.reg('radio', Ext.form.Radio);
\r