PDA

View Full Version : Add comment next to a field



perler
27 Nov 2007, 3:40 AM
Hi,

I want to add a comment next to a Textfield. Tried boxLabel but this only works with checkboxes.
Is there an easy way to add a descreption text at the top of a form? Which xtype do I have to chose?

Thanks!

efege
27 Nov 2007, 4:16 AM
Using a panel with just text (no header, borders, etc) allows to insert text boxes. This is only a first approximation to what you may be looking for:



new Ext.form.FormPanel({
width: 500,
height: 300,
bodyStyle: 'padding: 1em',
defaults: {border: false},
items: [
{html: 'This field is <b>very</b> important'},
{xtype: 'textfield', fieldLabel: 'Field 1'},
{html: 'This one not so important'},
{xtype: 'textfield', fieldLabel: 'Field 2'}
],
renderTo: document.body
})

perler
29 Nov 2007, 3:31 AM
pretty complicated isn't it?

Yossi
29 Nov 2007, 4:03 AM
pretty complicated isn't it?

Forget complicated, it's weird that you don't have an option to add a comment below or above a field. Or next to a field. Or a tool tips.
Even though there's great code that the community created for that..

Then again, when you build a framework like this one, it takes time. and a lot of coffee. and then much more debugging.

tryanDLS
29 Nov 2007, 8:25 AM
Why is it complicated? It's just one more item in the collection. You could always write a little wrapper function/object to do that for you.

new2ext
29 Nov 2007, 9:31 AM
I add another textfield, but hide the label and borders. Can't find the original post with the solution, but I add the following code:


var labelField = new Ext.form.Field({
labelSeparator:'',
value:'Text Label',
anchor: '100%'
})

labelField.getEl().setStyle({"background":"transparent", "border":"none", "overflow-y":"auto"});