How to customize dynamic attributes in form

Hi,
I want to customize dynamic attributes on my forms.
How to get components which belongs to dynamic attributes and put them another place of my layout.
form
Can you advice me how to do this.
I’m using 7.1 version of cuba.

Thanks,
Nurmuhammad.

The advantage of dynamic attributes is that managing them does not require changing application code.
On the Form and Table elements, they can be displayed automatically.
There is no way to add them directly to the screen descriptor markup.
They may not be available at the time of writing, and may be added to use.
You can display dynamic attributes on the screen using the Administration / Dynamic Attributes screen.
This is described in the documentation. Version 7.1 and 7.2 do not have significant changes.

Of course, you can place elements in the markup without data binding, and then fill in the screen elements from dynamic attributes in the screen controller. But this reduces their flexibility.

Hi @nurmuhammad.abdurashidov,

I think that @andreyvb mentioned DynamicAttributesPanel.

There is the possibility to customize as you said too. Take a look at the Managing Dynamic Attributes - Visibility of attributes.

Dynamic attributes can be added to a screen manually. In order to do this, add dynamicAttributes="true" attribute to the data loader and use attribute’s code with + prefix when binding UI components to it:

Hope it helps.

Regards,
Peterson.

1 Like

Thanks for your response Andrey,
Got what you mean.
so, how can i programmatically get some dynamic attribute components and put them another layout.
I’m getting dynamic attributes like this.

<column width="250px">
<field property="+CandidateMain_Document"/>
<field property="+CandidateDetails_LinkTelegram"/>
</column>

But in future, i don’t know my user adds how many fields to the entity.
That’s why, i should separate dynamic attributes to 2 parts, and put them their predefined layouts in future. For example: components which starts with ‘Main_ ***’ shout locate in first layout, components which starts with ‘Details_ ***’ shout locate in second layout.
image

Thanks,
Nurmuhammad

You can handle dynamic attributes like this and place them on the screen as you like:

Map<String, CategoryAttributeValue> dynamicAttributes  = newEntityDc.getItem().getDynamicAttributes();
            if (dynamicAttributes != null) {
                dynamicAttributes.forEach((key, value) -> {
                    Label<String> label = uiComponents.create(Label.TYPE_STRING);
                    if (key.startsWith("myCategoryright")) {
                        label.setValue(String.valueOf(value.getStringValue()));
                        rightVbox.add(label);
                    }
                    if (key.startsWith("myCategoryleft")) {
                        label.setValue(String.valueOf(value.getStringValue()));
                        leftVbox.add(label);
                    }
                });
            }

This is just an illustration for string attributes. It does not take into account possible types of dynamic attributes and other points.But the structure is quite transparent and you can implement what you need.
I attach a test project for experiments.
testdynamicattr.zip (84.4 KB)

Hi,

You can create several forms in your screen and specify them in the Dynamic Attribute Editor, in the Component ID column at the Visibility tab.
The only thing - you should create these forms in advance, ta development time and know their IDs.

See in documentation:
https://doc.cuba-platform.com/manual-7.2/dynamic_attributes_mgmt.html#dynamic_attributes_visibility

In addition to the screen, you can also specify a component in which the attribute should appear (for example, for screens where several Form components show the fields of the same entity).