Remove Value from Field that isn't visible

Duncan Koza asked on October 11, 2019 21:32

I am using Kentico 11 and am making portal pages. On one of my page types under the fields menu, I have a boolean radio button. When "Yes" is selected, it makes two text fields visible and adds validation so those two text fields are required when you save. When "No" is selected, they are not visible and no longer required.

The Problem I am having is... trying to figure out if it is possible to remove the value of the two text fields when "no" is selected. Any ideas?

Correct Answer

Mike Wills answered on October 14, 2019 06:38

Hi Duncan,

One way to do this is to handle a global system event, so that your code can check the field values of your page type, before saving. For example, you could use the DocumentEvents.Update.Before event. Or, if you are using workflow and versioning, you could use WorkflowEvents.SaveVersion.Before. This would allow you to check the value of the Boolean radio button, and clear field values accordingly.

Let me know if this helps.

Thanks,

Mike

0 votesVote for this answer Unmark Correct answer

Recent Answers


Duncan Koza answered on October 11, 2019 21:35

Right now, the only work around I have found is to always keep the fields visible, so you can manually delete the values if you had previously entered something, but I'd still like to know if it is possible to clear the values when you hit "no".

0 votesVote for this answer Mark as a Correct answer

Duncan Koza answered on October 16, 2019 19:59

Thank you Mike,

I am not sure how to do that, but I'll have to keep that in mind for a future date.

  • Duncan
0 votesVote for this answer Mark as a Correct answer

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