PDA

View Full Version : Feature request : label field for formpanel



gslender
30 Apr 2008, 5:23 AM
A html or label field for formpanel so you can add notes/instructions to forms.

I probably could extend Field - but before I do, is this something that Beta3 (or more) may eventually have?

darrellmeyer
30 Apr 2008, 11:50 AM
Yes, I agree. This feature will be added soon.

tcouery
11 May 2008, 4:39 AM
We had the same need.
Here is the component that we wrote:
You can use it freely



package com.extjs.gxt.ui.client.widget.custom.form;

import com.extjs.gxt.ui.client.widget.form.Field;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;

/**
* Basic Label Field
*/
public class LabelField extends Field {
public LabelField() {
super();
setElement(DOM.createDiv());
//Can be beter with a style
DOM.setStyleAttribute(getInputEl().dom, "padding", "3px 3px 3px 0pt");
}

@Override
public void setValue(Object value) {
super.setValue(value);
DOM.setInnerHTML(getInputEl().dom, value==null?"":value.toString());
}

@Override
public Object getValue() {
return DOM.getInnerText(getInputEl().dom);
}

@Override
protected void onRender(Element target, int index) {
el.insertInto(target, index);
}
}