Custom Page Type field conditional visibility

D D asked on June 20, 2016 21:40

I'm relatively new to kentico and am having some issue with creating a page type with conditional fields based off other fields. Basically I have a drop down list that shows one field if one value and another that shows if it's another value. I've been able to set dependency and visibility, but I want to clear out the conditional fields if the user selects one option, fills out that corresponding conditional text, then decides to change it to the other and do the same.

Can this be done?

Recent Answers

Trevor Fayas answered on June 20, 2016 22:00 (last edited on March 24, 2018 12:15)

You can use macros within the Values of a drop down. You can reference other fields just by {% TheFieldName.Value |(user)zbynekh|(hash)e2a1b12871c062183aad5664a8ab6b99acb7c21274a5d1a8b80ea6b75e0f8613%}

Here's kind of an example that i use, this is in a where condition

{% If(SomeField.Value == "SomeValue" ? "Select * from SomeTable" : "Select * from SomeOtherTable" |(user)zbynekh|(hash)b1b78373dcfb77ec81cd2abf777a4049ba893fa66776d490232d29ae68f5677d%}

You can also use macros then instead of a SQL where to build the drop down, to actually do a value thing, like below

{% If(SomeField.Value == "SomethingToTest" ? "Value1;Value 1" : "Value2;Value 2" |(user)zbynekh|(hash)e85ad8669c1ba0aebc6c47b47e759e6f2d48cd242ad7e32243517eeacbc4265b%}

If this helps, mark as solved for others!

0 votesVote for this answer Mark as a Correct answer

D D answered on June 20, 2016 22:49 (last edited on March 24, 2018 12:15)

I have my drop down as list of options. For example: Text A Text B Text C

Two textbox fields TextA and TextB

Would I switch it to macro expression instead and put the macros in there? ie {% (if dropdownlist.value == "Text A") ? TextA = "" |(user)zbynekh|(hash)8459cdfe6f301f5151b8162d92a3b4dc5a0e54d121da896cc578d2f9f0a73960%}

Something like that? Again I apologize for my level of experience.

0 votesVote for this answer Mark as a Correct answer

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