Toggle fields based on post-type field

Hello

I’m trying to create a togglable field based on the value of a post-type field.

Is this possible, or only with a select field?

I currently have the code below, but it’s not working:


/**
 * Register the module and its form settings.
 */
FLBuilder::register_module('FLActivityBlockStyleOne', array(
	'general'       => array( // Tab
		'title'         => __('General', 'xyz'), // Tab title
		'sections'      => array( // Tab Sections
			'general'       => array( // Section
				'title'         => '', // Section Title
				'fields'        => array( // Section Fields
					'title'          => array(
						'type'          => 'text',
						'label'         => 'Section Title',
					),
					'post_type'          => array(
						'type'          => 'post-type',
						'label'         => 'Post type',
						'toggle'        => array(
							'post'      => array(
								'fields'        => array('toggle_text'),
								'sections'      => array('general')
							)
						)
					),
					'toggle_text'   => array(
							'type'          => 'text',
							'label'         => __('Hide Me!', 'fl-builder'),
							'default'       => '',
							'description'   => 'I get hidden when you toggle the select above.'
					),
					'posts_per_page'  => array(
						'type'          	=> 'text',
						'label'         	=> 'Number to show',
					),
				)
			)
		)
	)
));

Thanks!

Hey Doug,

I’ve already assigned another member of the team to assist you with your concern.

Ben

Hi Doug,

Toggles only work with the select field type at the moment. We’d like to get them working with all fields, but unfortunately, that’s going to be a big project and not something we have planned for the near future.

In the meantime, you can write some custom JS in your module’s settings.js file to handle that. Let me know if you have any questions there.

Justin

Thanks Justin - no probs… I’ll do some digging first!