Dynamic form - conditional visibility (events trigger)

Hi team,

I am trying to create a form to manage users permissions in my tool.


When the user selects “Revoked” Membership, I want all the tools below to be disabled and to take the “None” value.
When the user selects “Administrator” Membership, I want all the tools below to be disabled and to take the “Administrator” value.

How can I achieve that?

Thank you for your help

You need to make all the Radio Buttons dynamic. And set the value on $evm.object

membership = $evm.root['dialog_membership']
...
$evm.object['read_only'] = true/false   # Enable the Radio Button
$evm.object['value'] = 'none'/'admin'   # Pre-select a value

Thanks for your answer. I am almost there.
So it was simpler than expected. I declared dynamic fields in my form, that I linked to the following method:

membership =  $evm.root['dialog_param_user_membership']
case membership
when 'Revoked'
  status = 'None'
  membership_value = 1
when 'Administrator'
  status = 'Administrator'
  membership_value = 4
end

list_values = {
    'required' => true,
    'values' => {1 => 'None', 2 => 'Guest', 3 => 'User', 4 => 'Administrator'},
    'value' => membership_value,
    'read_only' => true
}
 list_values.each do |key, value| 
   $evm.object[key] = value
 end

And I get the following result:

cf_almost_there

I know it looks like my previous screenshot :sweat_smile: :sweat_smile: but actually this one is fully dynamic whereas the previous one was static.

I think my declaration is not correct:
membership = $evm.root['dialog_param_user_membership']
How can I get the value of my radio button selected by the user?

You want configure the Membership Field to refresh the Radio Buttons below. I guess that is what you are looking for?
That’s in the Dialog Builder: “Fields to Refresh”
image

To access the value of Membership, you need to know the name of the field (which you configured in the Dialog Builder). To access the field, you just need to prefix the name with “dialog_”

$evm.root["dialog_#{field_name}"]

In any case, you can just dump the value of $evm.root to the log. It just a simple Ruby Hash :slight_smile:

$evm.log(:info, "DUMP EVM ROOT Keys: #{$evm.root.keys}")

Thanks so much for your answer.
But I need the value selected by the user in the radio button.
In the Membership radio button in my screenshot, if the user selected “Project Member”. How can I get the value “Project Member”?

You need the Label, not the value? I don’t understand why?
Can’t you just use the same string for Label and value? Or put a static mapping in your code to translate from value to label?

Finding the Label to a specific Dialog Element is not worth the effort.
You would have to fetch the Dialog from the Database and walk through the datamodel to find the definition of the radio button. On the Database level the dialogs look something like this Catalog Item > Dialog > Tab > Section > fields > Field Values


Can you screenshot, what you configured in the dialog builder?

1 Like

Hi, the theme is very interesting.

Apart from the discussed logic, I wonder how you was able to get such form?

I understand that the form in visual editor may be composed only with one label and one item in row. ( 2 columns only)

Your form is complex enough with many columns(and also colored)

So is it made by composing form by yaml or any other way?

I explored the yaml format of exported dialog and did not find the method of doing complex forms…

It is still only 2 columns. The Label is “Artifactory” the item is a radio button group with “None/Guest/User/Admin” as the choices.

Hi! Actually you gave me a hint to find the solution to my problem. I was iterating the values instead of the keys. Many thanks :pray: it works now!

Ah, never used radio buttons and indeed, the arrangement mimic the multicolumn.

But still I am very interested of how service dialogs are made by yaml.

I did not found any doc about format of yaml.

Can you point me to some?

Also, I wonder what is the format of the pre-build dialogs templates?

They looks different from format of service dialogs, and seems have more rich layouts,
like multi-column, table-like etc.

Hi,
I am using Cloudforms version: 5.9
The colors are there by default.
I created this form with a mix of the visual editor and ruby script (inline scripts - service dialog).
In the visual editor I configured dynamic fields waiting for the ruby script to populate them.

I managed thanks to online doc and with forums.
Depending on what you want to do, you will be able to find the doc online :fist:

Thanks. I use ManageIQ and there are no colors…

I was looking into this yesterday, and I don’t think they can do more complicated layouts. I did not find anything they do, that cannot be expressed in ServiceDialogs, except for Tables. (but I haven’t looked that much into it)

I doubt there is any documentation, the best you can do is probably study the YAML exports