Remove a field after selecting another field

Hello, I am not an expert in php but I managed to write this code.
I have a select field ‘test’ that I want to remove if select field ‘aircon_new_inst’ has a value of Maintenance.
Is there a way to do so?

add_filter(
	'hivepress/v1/forms/request_update',
	function( $form ) {
		if(isset($form['fields']['aircon_new_inst']) && $form['fields']['aircon_new_inst'] == 'Maintenance'){
		unset( $form['fields']['test'] );
		}
		return $form;
	},
	1000
);

Unfortunately, there’s no simple code snippet for implementing this feature in the current version.

Please try using Categories for category-specific fields, e.g. you can use categories to separate the request types and show different fields in the request form depending on the category.

If you want to make some Select attributes dependent on other Select attributes there’s also a workaround if you use a single Select attribute with hierarchical options.

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