4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
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.
19 * @param {Object} config Configuration options
21 Roo.form.Radio = function(){
22 Roo.form.Radio.superclass.constructor.apply(this, arguments);
24 Roo.extend(Roo.form.Radio, Roo.form.Checkbox, {
28 * If this radio is part of a group, it will return the selected value
31 getGroupValue : function(){
32 return this.el.up('form').child('input[name='+this.el.dom.name+']:checked', true).value;
36 onRender : function(ct, position){
37 Roo.form.Checkbox.superclass.onRender.call(this, ct, position);
39 if(this.inputValue !== undefined){
40 this.el.dom.value = this.inputValue;
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);
50 //this.el.on('DOMAttrModified', this.setFromHidden, this); //ff
51 //this.el.on('propertychange', this.setFromHidden, this); //ie
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);
60 this.el.dom.checked = 'checked' ;
65 * Sets the checked state of the checkbox.
66 * On is always based on a string comparison between inputValue and the param.
67 * @param {Boolean/String} value - the value to set
68 * @param {Boolean/String} suppressEvent - whether to suppress the checkchange event.
70 setValue : function(v,suppressEvent){
73 //this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on');
74 //if(this.el && this.el.dom){
75 // this.el.dom.checked = this.checked;
76 // this.el.dom.defaultChecked = this.checked;
78 this.setChecked(String(v) === String(this.inputValue), suppressEvent);
80 this.el.dom.form[this.name].value = v;
82 //this.fireEvent("check", this, this.checked);
85 setChecked : function(state,suppressEvent)
89 this.wrap[state ? 'addClass' : 'removeClass']('x-menu-item-checked');
92 if(suppressEvent !== true){
93 this.fireEvent('check', this, state);
101 // this.setValue(this.resetValue);
102 //this.originalValue = this.getValue();