View Full Version : Display a form fieldlabel as a button ???

4 Feb 2008, 6:06 PM
Hi everybody,

Does anyone know how could i display a form fieldlabel as a button ?

i think i would need to overwrite the template in Ext.layout.Formlayout.SetContainer function

var t = new Ext.Template(
'<div class="x-form-item {5}" tabIndex="-1">',
'<label for="{0}" style="{2}" class="x-form-item-label">{1}{4}</label>',
'<div class="x-form-element" id="x-form-el-{0}" style="{3}">',
'</div><div class="{6}"></div>'

and replace the label with a div but i have no idea on how can i do this ??

anyone here know how ??

thanks a lot

4 Feb 2008, 11:14 PM
Do you really want the Ext.Button style, or just a visual feedback that you can click on the label?

The second one is easier:

Leave the template as it is and after render use addClassOnOver and addClassOnClick on the x-form-item-label and add a click handler.

5 Feb 2008, 1:15 AM
Once more condor is flying to our rescue, thanks for the tips condor.

But !!!!

Yes i really want a button layout. If you already used outlook you'll see in the contact form that there's some fieldlabel where you can select phone1 phone2 phone3 ....... and once you selected the fieldlabel button the phone appear in the same textfield.

That's exactly what i want !!!

So i need the harder solution !!!

Any idea ??

5 Feb 2008, 1:21 AM
Why not use a column or table layout and include buttons and textfields (without fieldLabels) ?

5 Feb 2008, 1:30 AM
Waouuu what a quick answer !!!

you're right that's what i'll do in a first time.

But it i think it could be great for the Lib to have one option in fields that allow someone to do it like for example FieldLabelType. One day when i'll grow up i'll do it that way. Right now as i'm still a baby in the javascript world i'll do it the way you told me condor.

Thanks a lot