Building friendlier forms using text hints
Great usability is often attained with simple UI modifications. This recipe explains how you can make your forms easier to use by adding text hints to their contained fields. The next screenshot shows a form that contains text hints:
How to do it...
Create a form and use the emptyText
configuration option to add text hints to the fields:
Ext.onReady(function() { var commentForm = new Ext.FormPanel({ frame: true, title: 'Send your comments', bodyStyle: 'padding:5px', width: 550, layout: 'form', items: [{ xtype: 'textfield', fieldLabel: 'Name', name: 'name', anchor: '98%', allowBlank:false, emptyText:'Your name here' }, { xtype: 'textfield', fieldLabel: 'Email', name: 'email', anchor: '98%', vtype:'email' }, { xtype: 'textarea', fieldLabel: 'Comments', name: 'comments', anchor: '98%', height:200, allowBlank: false, emptyText: 'Enter your comments' }], buttons: [{ text: 'Send' }, { text: 'Cancel' }] }); commentForm.render(document.body);