4f83f53a7e171c210a5036413820e3afe79e2a85
[roojs1] / Roo / form / Radio.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11  
12 /**
13  * @class Roo.form.Radio
14  * @extends Roo.form.Checkbox
15  * Single radio field.  Same as Checkbox, but provided as a convenience for automatically setting the input type.
16  * Radio grouping is handled automatically by the browser if you give each radio in a group the same name.
17  * @constructor
18  * Creates a new Radio
19  * @param {Object} config Configuration options
20  */
21 Roo.form.Radio = function(){
22     Roo.form.Radio.superclass.constructor.apply(this, arguments);
23 };
24 Roo.extend(Roo.form.Radio, Roo.form.Checkbox, {
25     inputType: 'radio',
26
27     /**
28      * If this radio is part of a group, it will return the selected value
29      * @return {String}
30      */
31     getGroupValue : function(){
32         return this.el.up('form').child('input[name='+this.el.dom.name+']:checked', true).value;
33     },
34     
35     
36     onRender : function(ct, position){
37         Roo.form.Checkbox.superclass.onRender.call(this, ct, position);
38         
39         if(this.inputValue !== undefined){
40             this.el.dom.value = this.inputValue;
41         }
42          
43         this.wrap = this.el.wrap({cls: "x-form-check-wrap"});
44         //this.wrap = this.el.wrap({cls: 'x-menu-check-item '});
45         //var viewEl = this.wrap.createChild({ 
46         //    tag: 'img', cls: 'x-menu-item-icon', style: 'margin: 0px;' ,src : Roo.BLANK_IMAGE_URL });
47         //this.viewEl = viewEl;   
48         //this.wrap.on('click', this.onClick,  this); 
49         
50         //this.el.on('DOMAttrModified', this.setFromHidden,  this); //ff
51         //this.el.on('propertychange', this.setFromHidden,  this);  //ie
52         
53         
54         
55         if(this.boxLabel){
56             this.wrap.createChild({tag: 'label', htmlFor: this.el.id, cls: 'x-form-cb-label', html: this.boxLabel});
57         //    viewEl.on('click', this.onClick,  this); 
58         }
59          if(this.checked){
60             this.el.dom.checked =   'checked' ;
61         }
62          
63     } 
64     
65     
66 });