View Full Version : How to implement correctly a display field getValue methods (and getInputEl)

31 Jan 2012, 1:04 AM
I would like to write my own component. I know I wrote a question similar to this but it's rather different now.

Last time, I had to fight with the problem that I had to call an external javascript library method to generate some html content, so I required everything to work after a render method because I needed html markup. In this situation I couldn't really implement correctly a custom field (if you have better ideas suggest me).

This time I have to build a completely new field type, which will be something like a "tags field" (yea I know there are select box example but what I want is quite different). Also I would like to understand this for future components: Which class should I inherit and which method should I implement to effectively write a custom field?

I inherited from a display field but I need to write some html markup, where should I place it? should I implement getRawValue or getValue?

Are there any guidelines?

Be precise so I can correctly write a field implementation, I would like to make it behave like all other Field classes

Thanks a lot

31 Jan 2012, 6:53 AM
If you only want to have a displayfield with html content, then you can extend from it and probably set the html content in the value either via the value config or if you need to do it after render then the setValue

31 Jan 2012, 7:00 AM
Mh I didn't explain myself really well. I want to make a custom content and I think i NEED some html content. Suppose that I want a component that is composed by 2 <input type="text" />, I think I need to write some html (if I can have a different approach is ok).

I supposed this is done by implementing a display field, but maybe it's something different. I just would like to understand which class is supposed to be extended if I'm making a custom field that it's not similar to those that already exist.