Jump to content

\IPS\Helpers\Form\Select $toggles + $unlimitedToggles


newbie LAC

Recommended Posts

Hello,

 

$form = new \IPS\Helpers\Form();

$elements = array();
$options = array();
$toggles = array();
$unlimitedToggles = array();
$selected = -1;

foreach (array('foo', 'bar', 'baz') as $v)
{
	$options[$v] = $v;
	$k = 'test_select_toggles_' . $v;
	$toggles[$v] = array($k);
	$unlimitedToggles[] = $k;

	$elements[] = new \IPS\Helpers\Form\Text(
		$k,
		'',
		false,
		array(),
		null,
		null,
		null,
		$k
	);
}

$form->add(new \IPS\Helpers\Form\Select(
	'test_select_toggles_select',
	$selected,
	false,
	array(
		'options' => $options,
		'toggles' => $toggles,
		'multiple' => true,
		'unlimited' => -1,
		'unlimitedToggles' => $unlimitedToggles,
	)
));

foreach ($elements as $element)
{
	$form->add($element);
}

Result

toggles.jpg.5d466b7381c500e091a18f14b35b5beb.jpg

All works as expected


Change $selected = -1; to $selected = 'foo';

Result

toggles2.jpg.8ab2ac28aa6b175ebe5b6f2fa8a05509.jpg

It should also display test_select_toggles_foo element.


Remove 'unlimitedToggles' => $unlimitedToggles,

Result

toggles3.jpg.9d920f47365c4649489a211035e2ddce.jpg

So there is a conflict between 'toggles' and 'unlimitedToggles'

Link to comment
Share on other sites

Archived

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

  • Recently Browsing   0 members

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