Jump to content

Toggle on and off using select form settings


TheJackal84

Recommended Posts

Posted

Is the any way to use the 'toggleson' and 'togglesoff' feature using the select or checkbox form settings

For example

$form->add( new \IPS\Helpers\Form\Select( 'My_Setting', 
    \IPS\Settings::i()->My_Setting, FALSE, 
    array( 
    'app' => 'core', 
    'key' => 'Admin', 
    'autoSaveKey' => 'My_Setting', 
    'options' => array( 
        1 => 'TogglesOn$FormX', 
        2 => 'TogglesOff$FormY' ), 
    'multiple' => FALSE ),
    NULL, NULL, NULL, 'My_Setting') 
);

 

Posted

For Select uses 

	 		'toggles'			=> array( 'key' => array( ... ) )	// IDs that each option should show/hide when toggled

Example

$form->add(new \IPS\Helpers\Form\Select(
	'setting1',
	\IPS\Settings::i()->setting1,
	false,
	array(
		'options' => array(
			'option1' => 'option1_title', 
			'option2' => 'option2_title'
		),
		'toggles' => array(
			'option1' => array('setting2'),
			'option2' => array('setting3'),
		)
	)
));

$form->add(new \IPS\Helpers\Form\Number(
	'setting2',
	\IPS\Settings::i()->setting2,
	false,
	array(),
	null,
	null,
	null,
	'setting2'
));	

$form->add(new \IPS\Helpers\Form\Text(
	'setting3',
	\IPS\Settings::i()->setting3,
	false,
	array(),
	null,
	null,
	null,
	'setting3'
));

 

Posted
12 minutes ago, newbie LAC said:

For Select uses 


	 		'toggles'			=> array( 'key' => array( ... ) )	// IDs that each option should show/hide when toggled

Example


$form->add(new \IPS\Helpers\Form\Select(
	'setting1',
	\IPS\Settings::i()->setting1,
	false,
	array(
		'options' => array(
			'option1' => 'option1_title', 
			'option2' => 'option2_title'
		),
		'toggles' => array(
			'option1' => array('setting2'),
			'option2' => array('setting3'),
		)
	)
));

$form->add(new \IPS\Helpers\Form\Number(
	'setting2',
	\IPS\Settings::i()->setting2,
	false,
	array(),
	null,
	null,
	null,
	'setting2'
));	

$form->add(new \IPS\Helpers\Form\Text(
	'setting3',
	\IPS\Settings::i()->setting3,
	false,
	array(),
	null,
	null,
	null,
	'setting3'
));

 

Cheers I will give it a shot after breakfast I'm starving lol

Posted
$form->add( new \IPS\Helpers\Form\Select( 'My_Setting', \IPS\Settings::i()->My_Setting, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'My_Setting',
	'options' => array(
		1  => 'options1',
		2 => 'options2' ),
	 'toggles' => array(
		1 => array('togglethis_setting', '',''),
		2 => array('')
) ), NULL, NULL, NULL, 'My_Setting'));

 

Edit

Sorry, didn't see newbie LAC's post

anyways, same thing :) 

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...