Jump to content

\IPS\Helpers\Form\Node + toggleIds


newbie LAC

Recommended Posts

Posted

Hello,

I'm working on plugin and use \IPS\Helpers\Form\Node

	 		'toggleIds'			=> array(),						// Element IDs to toggle on when a node with 'togglePerm' permission IS selected - or, if togglePerm is NULL, an associtive array of elements to toggle when particular node IDs are selected

if togglePerm is NULL, an associtive array of elements to toggle when particular node IDs are selected

But this doesn't work

\applications\core\dev\html\global\forms\nodeCascade.phtml

{{if $togglePerm}}data-control="toggle" {{if $node->can( $togglePerm, NULL, $togglePermPBR )}}data-toggles="{expression="implode( ',', $toggleIds )"}"{{elseif !$togglePerm and isset( $toggleIds[ $node->_id ] )}}data-control="toggle" data-toggles="{expression="implode( ',', $toggleIds[ $node->_id ] )"}"{{elseif \count( $toggleIdsOff )}}data-toggles="{expression="implode( ',', $toggleIdsOff )"}"{{endif}}{{endif}}

Some formatting

{{if $togglePerm}}
	data-control="toggle" 
	{{if $node->can( $togglePerm, NULL, $togglePermPBR )}}
		data-toggles="{expression="implode( ',', $toggleIds )"}"
	{{elseif !$togglePerm and isset( $toggleIds[ $node->_id ] )}}
		data-control="toggle" data-toggles="{expression="implode( ',', $toggleIds[ $node->_id ] )"}"
	{{elseif \count( $toggleIdsOff )}}
		data-toggles="{expression="implode( ',', $toggleIdsOff )"}"
	{{endif}}
{{endif}}

 

Posted

Just pay attention on condition

If $togglePerm is NULL the toggle attributes will not be added.


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

$form->add( new \IPS\Helpers\Form\Node(
	'field1',
	0,
	true,
	array(
		'class' => 'IPS\calendar\Calendar',
		'multiple' => false,
		'toggleIds' => array(
			1 => array(
				'field2'
			),
			2 => array(
				'field3'
			)
		),
	)
));

$form->add( new \IPS\Helpers\Form\Text(
	'field2',
	'',
	true,
	array(),
	null,
	null,
	null,
	'field2'
));

$form->add( new \IPS\Helpers\Form\Text(
	'field3',
	'',
	true,
	array(),
	null,
	null,
	null,
	'field3'
));

 

Archived

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

  • Recently Browsing   0 members

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