ExtJS How to modify the textfield parameter autocomplete="off"

Farandole picture Farandole · Oct 8, 2012 · Viewed 9.4k times · Source

Some modern (Safari, chrom, firefox) browser records informations and allows you to autocomplete some textfields when you come back.

I want to do it in ExtJS. I have a piece of answer here :

How to get Chrome to remember login on forms?

But in ExtJS, I can not access to the parameter autocomplete. It is always hard coded autocomplete="off". In the doc, I do not found how to modify it : http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.Text

Is someone has a simple answer to modify this parameter ?

Answer

Neil McGuigan picture Neil McGuigan · Oct 8, 2012

You want to add an afterrender listener to the textfield, get a reference to the input element, and set its autocomplete attribute to "on". You probably also want to set its name (as that is how the browser remembers the value).

Example:

http://jsfiddle.net/4TSDu/19/

{
    xtype:'textfield',
    fieldLabel:'some field',
    name:'somefield',
    listeners:{
        afterrender:function(cmp){
            cmp.inputEl.set({
                autocomplete:'on'
            });
        }
    }
}