Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EXTJS TextField Help in the side

Tags:

extjs

I want to add like a ? beside of a TextField so as if the mouse pases over, it shows some help How can I do it please. Thnx

like image 488
Marouane Gazanayi Avatar asked Oct 31 '10 20:10

Marouane Gazanayi


1 Answers

Many ways to do this, and many different levels of complexity, but at it's simplest I might do something like this...

Add an interceptor function to the Fields init method that adds the question mark and uses qtip's to display a message - this allows all types of fields that inherit from the Field class to have this functionality.

For example:

Ext.intercept(Ext.form.Field.prototype, 'initComponent', function() {
  var fl = this.fieldLabel, h = this.helpText;
  if (h && h !== '' && fl) {
    this.fieldLabel = fl+'<span style="color:green;" ext:qtip="'+h+'">?</span> ';
  }
});

Then in each field definition you would have a helpText property:

{
   fieldLabel: 'First Name',
   helpText: 'This is your first name dummy!',
   name: 'first',
   allowBlank:false
}

This produces:

alt text

Im sure you can expand on it from what I have provided, and if you need more info on interceptors, check out my blog post on them.

Enjoy!

like image 155
Shea Frederick Avatar answered Sep 28 '22 08:09

Shea Frederick