0

In Craft CMS 5, I have several conditional fields that display or hide based on the value of a Category field (single selection).

Depending on the selected category, different fields appear: Date, Table (a table of dates), or Matrix (multiple tables of dates).

The problem is that if I change the category, the value of the previously displayed and now hidden conditional field is not cleared. Even though the field is hidden in the Control Panel, its value still appears in the Twig template. How can I solve this issue?

However, how can I retrieve the condition in EVENT_AFTER_SAVE_ELEMENT to apply a reset like $entry->setFieldValue('fieldHandle', null); when necessary?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.