Results 1 to 5 of 5

Thread: htmlDecode for text fields and combos.

  1. #1
    Sencha Premium Member
    Join Date
    Apr 2011
    Posts
    14
    Answers
    1

    Default Answered: htmlDecode for text fields and combos.

    I am getting html encoded data back from the server. Where is the best place to apply Ext.String.htmlDecode() for text fields?
    Is doing the following a safe option?
    PHP Code:
    Ext.define('mypatches.form.field.Text', {  
      
    override'Ext.form.field.Text',
      
    setValue: function (value) {
       
    value Ext.String.htmlDecode(value);    
       return 
    this.callParent(arguments);       
      }
    }); 
    Combo's seem to do half the html decoding already (see picture) where should the override be for a combo?
    I have gone through the forum and found this post but it has not worked.
    Thanks
    Masood

    combo.png

  2. Thanks Gary. I had to make the following change for combos, otherwise the value submitted is only the display text and not the id.

    PHP Code:
    //For combo
    Ext.define('mypatches.form.field.ComboBox', {  
      
    override'Ext.form.field.ComboBox',
      
    initComponent: function () {    
        
    this.displayTpl = new Ext.XTemplate(      
          
    '<tpl for=".">' +        
            
    '{[Ext.String.htmlDecode(typeof values === "string" ? values : values["' +       this.displayField '"])]}' +
             
    '<tpl if="xindex < xcount">' this.delimiter '</tpl>' +
          
    '</tpl>'    
        
    );    
       
    this.callParent(arguments);  
      }
    });

    //For text fields
    Ext.define('mypatches.form.field.Text', {
      
    override'Ext.form.field.Text',  
      
    transformRawValue: function(value) {
        return 
    Ext.String.htmlDecode(value);    
      }
    }); 

  3. #2
    Sencha Premium Member
    Join Date
    Apr 2011
    Posts
    14
    Answers
    1

    Default Did some more digging..

    Did some more digging and this seems to work for both combos and text fields.
    But still would be great to hear from someone more knowledgeable to say if this is fine or not...
    PHP Code:
    Ext.define('mypatches.form.field.Text', {  
      
    override'Ext.form.field.Text',
      
    transformRawValue: function(value) {    
       return 
    Ext.String.htmlDecode(value);  
      }
    }); 

  4. #3
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    What you are doing seems reasonable to me, though someone with more experience may chime in to enlighten.

  5. #4
    Sencha Premium Member
    Join Date
    Apr 2011
    Posts
    14
    Answers
    1

    Default

    Thanks Gary. I had to make the following change for combos, otherwise the value submitted is only the display text and not the id.

    PHP Code:
    //For combo
    Ext.define('mypatches.form.field.ComboBox', {  
      
    override'Ext.form.field.ComboBox',
      
    initComponent: function () {    
        
    this.displayTpl = new Ext.XTemplate(      
          
    '<tpl for=".">' +        
            
    '{[Ext.String.htmlDecode(typeof values === "string" ? values : values["' +       this.displayField '"])]}' +
             
    '<tpl if="xindex < xcount">' this.delimiter '</tpl>' +
          
    '</tpl>'    
        
    );    
       
    this.callParent(arguments);  
      }
    });

    //For text fields
    Ext.define('mypatches.form.field.Text', {
      
    override'Ext.form.field.Text',  
      
    transformRawValue: function(value) {
        return 
    Ext.String.htmlDecode(value);    
      }
    }); 

  6. #5
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    Thanks for posting your solution for the community.

Tags for this Thread

Posting Permissions

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