View Full Version : Formating the FieldLabel in a TextField

8 Mar 2009, 11:59 PM
I would like to format the FieldLabel in a TextField. I would like to set it with a label identifying the field and display align right its unit in bold.


Length_________ m:____ 20
Car Speed ______m/s:__ 100

Here I have used underscore to simulate the alignment :-(

I have used:

{fieldLabel:'Length <b>m</b>' ...}

to highlight the units, but I have not managed the units to align to the right of the fieldLabel.

Does anyone have any suggestion how I could do this?


9 Mar 2009, 5:20 AM
Search forums please, I have a feeling that I've seen something similar already.

9 Mar 2009, 5:28 AM
Couldn't you just use HTML and CSS since we're just writing an HTML document?


fieldLabel: 'Length <div class="label-right">m</div>'

And then

.x-form-item label div.label-right {
position: absolute;
right: 0px;

9 Mar 2009, 5:46 AM
Hmm. It doesn't seem like you can. <label> doesn't appear to like innerHTML which has divs.

9 Mar 2009, 6:02 AM
Thanks Animal,

Like you have discovered... label does not seem to like the div. When I look at the div Firebug tells me that the div is not embedded in the label.

Saki, I have been looking in the Forum for that last hour and I cannot find the info I am looking for. It is huge ... Thanks anyway will search more...

9 Mar 2009, 6:09 AM
Looks like labels accept DOM addition of child nodes, so you could postprocess the Field's DOM on render, and poke around inside the label element.