Results 1 to 5 of 5

Thread: ComboBox with ForceSelection does not do validation correctly

    You found a bug! We've classified it as EXTJS-17890 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha Premium Member
    Join Date
    Jul 2014
    Location
    Freiburg, Germany
    Posts
    165
    Vote Rating
    12
      0  

    Default ComboBox with ForceSelection does not do validation correctly

    Hi,

    ExtJs Version: 5.1.1

    Fiddle: https://fiddle.sencha.com/#fiddle/n6j

    ComboBox with 'allowBlank: false' and 'forceSelection: true' is not displaying empty value is invalid.

    Reproducing the bug

    - goto fiddle
    - (combobox is correctly marked as invalid, as no value is selected)
    - click inside the combo and type 'xxxxxx'
    - now either Tab out of the box, or just click somewhere outside
    => combobox has no value, but is marked as valid

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Vote Rating
    292
      0  

    Default

    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2014
    Location
    Freiburg, Germany
    Posts
    165
    Vote Rating
    12
      0  

    Default

    For anyone interested in a quick and dirty workaround:

    Blur Callback of the Combobox
    Code:
    blur: function(self) {
        if (!this.allowBlank && this.getValue() === null) {
            this.markInvalid('This field is required.');
        }
    }

  4. #4
    Sencha Premium Member
    Join Date
    May 2011
    Posts
    28
    Vote Rating
    3
      0  

    Default

    This Bug is still existing in ExtJS 6.5.3!

    I use this as workaround:

    Code:
    listeners: {
       afterrender: function(combo){
          combo.validate();
       }
    }

  5. #5
    Sencha Premium User
    Join Date
    Dec 2016
    Posts
    5
    Vote Rating
    0
      0  

    Default another work around

    This override has resolved the issue for me so far:

    Code:
        override: 'Ext.form.field.ComboBox',
    
        initComponent: function () {
            this.callParent();
    
            if (this.allowBlank === false && this.forceSelection === true) {
                this.on({
                    blur: function () {
                        if (Ext.isEmpty(this.getValue())) {
                            this.wasValid = false
                        }
                    }
                })
            }
        }

Similar Threads

  1. Replies: 2
    Last Post: 14 Nov 2013, 6:54 PM
  2. Combobox forceSelection
    By Swiff in forum Ext 3.x: Help & Discussion
    Replies: 11
    Last Post: 10 Jan 2010, 9:08 PM
  3. [2.2] ComboBox forceSelection Bug?
    By Eric24 in forum Ext 2.x: Bugs
    Replies: 3
    Last Post: 4 Nov 2008, 8:48 AM
  4. combobox and forceSelection
    By wehtam in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 24 Apr 2008, 7:09 AM
  5. forceSelection ComboBox
    By napolennon in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 24 Mar 2008, 1:38 AM

Posting Permissions

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