Results 1 to 4 of 4

Thread: BasicForm updateRecord bug?

    Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.
  1. #1
    Sencha Premium User
    Join Date
    Jun 2011
    Location
    Toronto
    Posts
    96

    Default BasicForm updateRecord bug?

    Not sure if this is a bug or feature...

    Converting from ExtJs4 to ExtJs6. I have a form with a checkbox with a name 'enabled' and an inputValue of true - actually the inputValue has no impact on this design.

    Anyway, I 'bind' a record to a form, make whatever changes and then use code like this:

    Code:
    basicForm.updateRecord(boundRecord);
    Anyway in EXTJS4 if the enabled checkbox is checked, it set's the record's enabled field to true, and if the checkbox is not checked, it sets the record's enabled field to false.

    This no longer works the same in EXTJS6...

    In EXTJS6, if the enabled checkbox is checked, it set's the record's enabled field to true (or whatever the inputValue is set to), and if the checkbox is not checked, it does nothing!

    It could have been a bug in EXTJS4 that developer's inadvertently utilized :-)

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for the report. Can you please post a test case which exhibits the behavior you are reporting?
    https://fiddle.sencha.com/#home

  3. #3
    Sencha Premium User
    Join Date
    Jun 2011
    Location
    Toronto
    Posts
    96

    Default

    Here is my quick attempt at a code sample based on the sample from your grid documentation:

    Code:
    Ext.create('Ext.data.Store', {
        storeId:'simpsonsStore',
        fields:['name', 'email', 'phone', 'married'],
        data:{'items':[
            { 'name': 'Lisa',  "email":"[email protected]",  "phone":"555-111-1224", married: false  },
            { 'name': 'Bart',  "email":"[email protected]",  "phone":"555-222-1234", married: false },
            { 'name': 'Homer', "email":"[email protected]",  "phone":"555-222-1244", married: true  },
            { 'name': 'Marge', "email":"[email protected]", "phone":"555-222-1254", married: true  }
        ]},
        proxy: {
            type: 'memory',
            reader: {
                type: 'json',
                root: 'items'
            }
        }
    });
    
    
    
    
    var gridPanel=Ext.create('Ext.grid.Panel', {
        title: 'Simpsons',
        store: Ext.data.StoreManager.lookup('simpsonsStore'),
        columns: [
            { text: 'Name',  dataIndex: 'name' },
            { text: 'Email', dataIndex: 'email', flex: 1 },
            { text: 'Phone', dataIndex: 'phone' },
            { text: 'Married', dataIndex: 'married' }
        ],
        height: 200,
        region: 'north'
    });
    
    
    var editPanel=Ext.create('Ext.form.Panel', {
    	id: 'detailPanel',
        frame: true,
        title: 'Edit Person',
        region: 'center',
        items: [
           {
        	   xtype: 'textfield',
        	   fieldLabel: 'Name',
        	   name: 'name'
        }, {
    	   xtype: 'checkbox',
    	   fieldLabel: 'Married',
    	   name: 'married',
    	   inputValue: true
    }],
        buttons: [{text: 'Save', handler: function() {
            var detailPanel = Ext.getCmp('detailPanel');
            detailPanel.getForm().updateRecord();
        }}]
    });
    
    
    gridPanel.getSelectionModel().on('selectionchange', function(sm, selectedRecord) {
        if (selectedRecord.length) {
            var detailPanel = Ext.getCmp('detailPanel');
            detailPanel.getForm().loadRecord(selectedRecord[0]);
        }
    });
    
    
    
    
    Ext.create('Ext.panel.Panel', {
        height: 400,
        width: 400,
        layout: 'border',
        items: [gridPanel, editPanel],
        renderTo: Ext.getBody()
    });
    When I run this in ExtJS4, it doesn't matter whether I select true (checked) or false (unchecked) for the Married Checkbox when I am editing one of the list items. Pressing Save will always update the married field to true or false to match the checkbox.

    In ExtJs6, pressing Save will only update the married field for the selected record if the Married checkbox is true (checked). When the married field is false (unchecked) the updateRecord() method doesn't set the married field in the selected record to false.

    The more I think about it, the more I think it was actually a bug in ExtJs4. I think that ExtJs6 is working correctly in that it only updates record fields for which their are form field values - and when a checkbox is unchecked, it doesn't really have a value!

    Anyway, hopefully this demos the issue

  4. #4
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    1

    Default Override Ext.form.field.Checkbox

    I experienced the same issue after upgrading from ExtJs4 to 6. I've found a couple of configs which restore the checkbox previous behavior from ExtJs 4:

    inputValue: true,
    uncheckedValue: false

    I've created an override for Ext.form.field.Checkbox and it would appear to be working nicely again now.

    Hope that helps.

Similar Threads

  1. BasicForm - updateRecord
    By hpet in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 19 Mar 2012, 11:07 PM
  2. BasicForm updaterecord ignoring fieldset checkboxName
    By Nigel in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 5 May 2011, 8:37 AM
  3. Replies: 7
    Last Post: 17 Jan 2011, 3:07 AM
  4. BasicForm updateRecord
    By petard in forum Ext 1.x: Bugs
    Replies: 1
    Last Post: 23 Apr 2007, 7:09 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
  •