How to create a custom component "from scratch"?

Hi all,

I need to add a picker field to my application where I can select from a set of predefined entries but the field should be a text field where you can also enter custom text that is not part of the predefined entires. So the picker just selects a value for the ease of use and writes it in the text field (string).
I did not find such a component and was wondering if we can create such a component with CUBA and use it in screens by using it in the layout xml?

Thanks for any pointers!
Oliver

Hello, yes its possible in several ways.

https://doc.cuba-platform.com/manual-7.2/own_components.html
You can wrap some existing JavaScript components, or you can make your own - composite component, but you can also make a facet or a fragment, depending on your needs.

Can even add them to the CUBA Studio pallete Support for Custom Visual Components and Facets in CUBA Studio - CUBA Platform. Developer’s Manual , but that’s not necessary to use them in XLM descriptors.

I think you need something like this, read carefully and try to recreate it, then move on your own:
https://doc.cuba-platform.com/manual-7.2/composite_components.html

Kind regards,
Mladen

1 Like

Thank you very much, I appreciate it! :slight_smile:

Hi Oli,

I’m guessing here a little, but it sounds like what you need is this one: https://demo10.cuba-platform.com/sampler/#main/2/sample?id=user-input-lookupfield

You can basically capture custom entries and then store the corresponding value in a string field. The initial options you can load when the screen loads and add to the options list.

Cheers
Mario

Hi Mario,

Sorry for the late reply, I was on vacation :wink:
Thank you, that seems to be exactly what I was looking for!

1 Like