Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: [FIXED-518][3.x/2.x] Bug in radiogroup when using brackets in name

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1

    Default [FIXED-518][3.x/2.x] Bug in radiogroup when using brackets in name

    When I use square brackets (] or [) in the name of the items of a radiogroup (which is within a FormPanel), they don't work in Firefox. My code looks like this:
    Code:
    ...
    { fieldLabel:'gender',
      xtype: 'radiogroup',
      items: [
        {boxLabel: 'Female',inputValue:'f', name:'data[Student][gender]'},
        {boxLabel: 'Male',inputValue:'m', name:'data[Student][gender]'}
      ]
    }, ...
    Actual Problem:
    It renders correctly, but when I want to use them, an error occurs:
    Code:
    [Exception... "'Error parsing selector, parsing failed at "]"' when calling method: [nsIDOMEventListener::handleEvent]"  nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)"  location: "<unknown>"  data: no]
    
    Line 0
    Additional information:
    The same happens when I use a single radiobutton with square-brackets in it's name. It works fine in Safari though...

    Adapter used: ext-base
    Firefox version: 2.0.0.16
    OS: Mac OS 10.4.11

    Btw: because I use CakePHP as underlaying framework, I need to use these brackets in the fieldnames.

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    There is a problem with the regular expression for attribute matching in DomQuery.

    A possible workaround is to alter the regular expression a bit (by making the closing quote mandatory after an opening quote) and use quotes in the Ext.form.Radio name (and optionally value) matching.

    For Ext 2.x:
    Code:
    Ext.DomQuery.matchers[2] = {
        re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?(["']?)(.*?)\4)?[\]\}])/,
        select: 'n = byAttribute(n, "{2}", "{5}", "{3}", "{1}");'
    };
    Ext.override(Ext.form.Radio, {
        getGroupValue : function(){
            var c = this.getParent().child('input[name="'+this.el.dom.name+'"]:checked', true);
            return c ? c.value : null;
        },
        toggleValue : function() {
            if(!this.checked){
                var els = this.getParent().select('input[name="'+this.el.dom.name+'"]');
                els.each(function(el){
                    if(el.dom.id == this.id){
                        this.setValue(true);
                    }else{
                        Ext.getCmp(el.dom.id).setValue(false);
                    }
                }, this);
            }
        },
        setValue : function(v){
            if(typeof v=='boolean') {
                Ext.form.Radio.superclass.setValue.call(this, v);
            }else{
                var r = this.getParent().child('input[name="'+this.el.dom.name+'"][value="'+v+'"]', true);
                if(r && !r.checked){
                    Ext.getCmp(r.id).toggleValue();
                };
            }
        }
    });
    For Ext 3.x:
    Code:
    Ext.DomQuery.matchers[2] = {
        re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?(["']?)(.*?)\4)?[\]\}])/,
        select: 'n = byAttribute(n, "{2}", "{5}", "{3}", "{1}");'
    };
    Ext.override(Ext.form.Radio, {
        getGroupValue : function(){
            var p = this.el.up('form') || Ext.getBody();
            var c = p.child('input[name="'+this.el.dom.name+'"]:checked', true);
            return c ? c.value : null;
        },
        onClick : function(){
            if(this.el.dom.checked != this.checked){
                var els = this.getCheckEl().select('input[name="' + this.el.dom.name + '"]');
                els.each(function(el){
                    if(el.dom.id == this.id){
                        this.setValue(true);
                    }else{
                        Ext.getCmp(el.dom.id).setValue(false);
                    }
                }, this);
            }
        },
        setValue : function(v){
            if (typeof v == 'boolean') {
                Ext.form.Radio.superclass.setValue.call(this, v);
            } else {
                var r = this.getCheckEl().child('input[name="' + this.el.dom.name + '"][value="' + v + '"]', true);
                if(r){
                    Ext.getCmp(r.id).setValue(true);
                }
            }
            return this;
        }
    });
    Last edited by Condor; 27 Jul 2009 at 7:32 AM. Reason: Added Ext 3.x override

  3. #3

    Default Works allright

    Yes, that works fine! I'll test it in Internet Explorer later on. Thanxs for the help. Is this going to be part of a future version, or is it to specific?

  4. #4
    Ext JS Premium Member
    Join Date
    Jan 2008
    Posts
    50

    Default

    This problem works fine for radios in a form.
    But it results in an error when using checkbox in a tree
    A single click doesn't get registered anymore ?

  5. #5
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    This shouldn't affect checkboxes at all!

    Are you using a normal tree with checkboxes or are you using my themed checkbox extension?

    Can you post an example?

  6. #6
    Ext JS Premium Member
    Join Date
    Jan 2008
    Posts
    50

    Default

    Sample code :

    Code:
    {
        title: 'Rechten',
        xtype: 'treepanel',
    
            useArrows:true,
            autoScroll:true,
            animate:false,
            enableDD:false,
            containerScroll: true,
    
    //dataUrl: '/customers/<%= @customer.id %>/permissions.json',
    
            // auto create TreeLoader
         loader: new Ext.tree.TreeLoader({
            dataUrl:'/customers/<%= @customer.id %>/permissions.json',
            requestMethod: 'get'
    
        }),
    
          root : new Ext.tree.AsyncTreeNode({
    text : 'Main Package',
    draggable :false ,// disable root node dragging
    id :'0',
    checked: false
     
    })
        }
    I just use a normal tree with checkbox
    It seems to be a problem in :

    Code:
    Ext.DomQuery.matchers[2].re = /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?(?:"(.*?)"|'(.*?)'|(.*?)))?[\]\}])/;
    When i lose this statement it all works fine ? (except the radio's with brackets in a form

  7. #7
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    Yes, the regexp was wrong. I've updated my code above.
    Last edited by Condor; 24 Jun 2009 at 4:31 AM. Reason: Fixed regexp

  8. #8
    Ext JS Premium Member
    Join Date
    Jan 2008
    Posts
    50

    Default

    Thanks, worked like a charm, thank you very much !

    Will keep it in mind in the future if i run into the same type of problem
    Last edited by dewie; 27 Nov 2008 at 12:18 PM. Reason: addon

  9. #9
    Sencha User
    Join Date
    Nov 2008
    Posts
    163

    Default

    thanks much!

  10. #10
    Sencha Premium User
    Join Date
    Dec 2007
    Location
    Stuttgart, DE
    Posts
    51

    Default

    Sorry - contents removed as I posted this one with the wrong account active,
    Last edited by sgehrig; 2 Feb 2010 at 8:08 AM. Reason: posted with wrong account

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 7
    Last Post: 17 Jan 2011, 3:07 AM
  2. Replies: 2
    Last Post: 29 Dec 2010, 9:38 AM
  3. [FIXED-518] 0.99 - Stack Overflow
    By alikic in forum Sencha Touch 1.x: Bugs
    Replies: 3
    Last Post: 9 Nov 2010, 4:58 PM
  4. Replies: 3
    Last Post: 15 Oct 2010, 12:48 PM
  5. [FIXED][3.0.0] RadioGroup SetValue() Bug
    By Dave.Sanders in forum Ext 3.x: Bugs
    Replies: 2
    Last Post: 20 Jul 2009, 9:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •