Search code examples
javascriptformsextjsextjs5

Get labelField text and form field values together


I intend to build a text with the text of labelField and textfield value

In my fiddle example the text of the fieldLabel is created dynamically.

what I want to achieve is to generate a text with the text of fielLabel and the value of the textfield.

https://fiddle.sencha.com/#fiddle/1icj

As is the fiddle displays "Homer, Simpson"

What I want to achieve: "Name Homer, Last Name Simpson"

It seems to me there is no method which gives the value of fieldLabel.

How to achieve this?

It is possible in some way, using binding?

What if I use a custom property, it is possible to obtain its value?


Solution

  • buttons: [{
            text: 'GetValues',
            handler: function() {
                var formValues = this.up('form').getForm().getValues();
                console.log(formValues);
    
                var finalValues = [];
                var needsLineBreak = false;
    
                if (formValues != null) {
                    var form=this.up('form'),
                        index=0;
                    Ext.iterate(formValues,function(key,val){
                        finalValues += form.getComponent(index).getFieldLabel()+':';
                        finalValues += val + ',';
                        index++;
                    });   
                  finalValues=finalValues.slice(finalValues.lenght,-1);
                }
                 console.log(finalValues);
            }
        }],