Dynamically Toggle Field with custom React UI
Hi all, I'm working with a custom UI implementation in React and I'm trying to work with the "Dynamically Toggle Visibility of a Form Field" with the idea of showing a checkbox if there is a specific country selected, but, there is a problem because we are overriding the form with our components, and the field that should be hidden waiting for the country selection is always rendered.
This is more or less how we render our components
switch (props.field.dataType) {
case "email":
return <EmailField {...props} />;
...
case "select":
return <SelectField {...props} />;
case "checkbox":
return <CheckboxField {...props} />;
default:
return null;
}So my question is if there is a way to achieve the behavior of the Field Toggle tutorial with a custom implementation, I tried to add a useEffect to react to the field changes and after that link somehow the fields that are related, but I don't know how to create a listener to the Marketo values, I just got this line to get the values but only once mktoForms2.getForm(formId).getValues(), and I don't know if there is a way to permanently listen if some value changes, or if there is another way to achieve the hide/show of the checkbox based on the value of the select field.
As an extra info the checkbox should be rendered and required only if certain country is selected (all of this rules coming from the marketo panel)
Any help or guidance will be really appreciated
Thanks
Jordan