Is conditional description area form field possible?

My Mautic version is: 4.4.9
My PHP version is: 8.0

I have a contact form. The first field is a drop down where the user can select the subject they want to discuss. When they select technical support I want to hide all of the other input fields (name, email, message) and instead display some text directing them to visit the support ticket area of my website.

My idea was to use a description are to display this info to the user, but it seems it’s not possible to use that as a conditional field, is that correct?

Could you suggest an alternative implementation?

Thanks.

there is no out-of-the-box configuration to do that, but you can use javascript to hide and show fields based on the onchange events of text or dropdown field. in practice all fields are loaded into the page and you control what the user can see. another approach, is to separate the fields into different forms, after submitting the first form you would redirect the user to form B or C, depending on the values of the form, this redirect is also done with javascript.

1 Like

Thanks, worked perfectly. Here’s my js snippet for anyone interested.

const technicalSupport = document.getElementById('mauticform_contact_technical_support');

const subject = document.getElementById('mauticform_input_contact_subject');

// Add an onchange event listener to the select element
subject.onchange = function() {
	let value = subject.value;

	if (value === 'technical-support')
		technicalSupport.style.display = "block";
	else
		technicalSupport.style.display = "none";
};

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.