Form field visibility condition

Petr Nejedly asked on February 1, 2021 11:37

Hi,

I would like to use the form field visibility condition feature. For example, I have a form rendered on page and I want to show a "Where did you hear about us" Radio buttons form field only if another field has a certain value (e.g. Country == "Czech Republic").

I set up the condition on the Radio buttons field (Visible if "some field" equals "some value") and now I need to make a front-end app aware of these visibility conditions.

When iterating through the List of FormField items, there is a VisibilityConditionConfigurationXmlData property containing the following XML for the "RadioButtonsWhere" (that is the name I used for my field) form field:

<?xml version="1.0"?>
<VisibilityConditionConfiguration>
  <Identifier>Kentico.AnotherStringField</Identifier>
  <VisibilityCondition>
    <DependeeFieldGuid>7319a3d1-de54-4fa5-ab7a-5d9f122bb4e5</DependeeFieldGuid>
    <ComparisonType>Equal</ComparisonType>
    <CompareToValue>Czech Republic</CompareToValue>
  </VisibilityCondition>
</VisibilityConditionConfiguration>

That is almost what I need, except I don't need the DependeeFieldGuid, I need something like DependeeFieldName.

Is there a way how can I translate the DependeeFieldGuid to Field Name, please?

Kind regards,

Petr

Correct Answer

Dmitry Bastron answered on February 1, 2021 13:17

Hi Petr,

You can resolve this guid into field name from CMS_Class table 9which stores all Kentico object's definition). Query something like:

select *
from CMS_Class
where ClassName = 'Form.Class.Name'

And check out ClassFormDefinition field.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Petr Nejedly answered on February 1, 2021 13:19

Hi Dmitry, thank you very much! All the best, Petr

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.