Results 1 to 3 of 3

Thread: [CLOSED][B3] Field mixin getValue always returns string on form.getValues

Hybrid View

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

    Default [CLOSED][B3] Field mixin getValue always returns string on form.getValues

    I have the following component I've developed (code below) for our ExtJS4 application, built on top of CouchDB. The field, I want to be able to save as an array in our database, which will be like this: [2, "Days"]

    In the below code, up to the console.log the value is fine, however when I do form.getValues this is always converted to a string as "2,Days" which isn't much use to me.

    Ext.define('QM.ux.TimespanField', {
      extend: 'Ext.form.FieldContainer',
      mixins: {
        field: 'Ext.form.field.Field'
      alias: 'widget.timespan',
      getValue: function() {
        var prefix, suffix, value;
        prefix = this.down('#prefix').getRawValue();
        suffix = this.down('#suffix').getRawValue();
        value = [prefix, suffix];
        return value;
      setValue: function(value) {
      initComponent: function() {
        Ext.apply(this, {
          layout: 'hbox',
          flex: 1,
          fieldDefaults: {
            allowBlank: true
          defaults: {
            layout: '100%'
          items: [
              xtype: 'numberfield',
              name: 'prefix',
              itemId: 'prefix',
              flex: 1,
              hideLabel: true,
              minValue: 1,
              maxValue: 999,
              allowDecimals: false,
              accelerate: true,
              submitValue: false
            }, {
              xtype: 'combo',
              name: 'suffix',
              itemId: 'suffix',
              flex: 1,
              hideLabel: true,
              editable: false,
              queryMode: 'local',
              store: this.createSuffixStore(),
              displayField: 'suffix',
              valueField: 'suffix',
              submitValue: false
        return this.callParent(arguments);
      createSuffixStore: function() {
        return Ext.create('', {
          fields: ['suffix'],
          data: [
              suffix: 'Minutes'
            }, {
              suffix: 'Hours'
            }, {
              suffix: 'Days'
            }, {
              suffix: 'Weeks'
            }, {
              suffix: 'Months'
            }, {
              suffix: 'Years'
    The form itself that uses this is also not doing the posting, the form handles record from the store of the type that uses this. So when saving a form, it handles it like this:

    saveItem: function(button) {
        var form, record, store, values, win;
        win = button.up('window');
        form = win.down('form');
        values = form.getValues();
        record = form.getRecord();
        store = this.getAssetsStore();
        if (!record) {
          record = new QM.model.Asset(values);
          store.insert(0, record);
        } else {
        return win.close();
    I think the problem is the assumption here in the existing code as that form.getValues should encode the values, when I would expect this to be done at the store or model level with a writer.

    This worked fine in ExtJS3, here is the ExtJS3 version for comparison:

  2. #2


    (source keeps messing up for some reason, link to gist instead:

  3. #3
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Sydney, Australia


    You'll want to use the getFieldValues method, it was added for the next release.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Similar Threads

  1. Replies: 1
    Last Post: 12 Jul 2010, 10:55 AM
  2. Replies: 3
    Last Post: 21 Apr 2010, 12:03 PM
  3. [CLOSED][3.0r5636] form.getValues returns displayField
    By Drayton in forum Ext 3.x: Bugs
    Replies: 9
    Last Post: 21 Nov 2009, 5:14 AM
  4. Replies: 6
    Last Post: 20 Apr 2009, 8:11 PM
  5. Replies: 4
    Last Post: 5 Nov 2007, 11:15 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