ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
with_select_child_nodes.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
21
26
40function with_select_child_nodes(): string
41{
42 global $DIC;
43
44 $factory = $DIC->ui()->factory();
45 $renderer = $DIC->ui()->renderer();
46
47 $node_retrieval = new class () implements NodeRetrieval {
48 public function getNodes(
49 NodeFactory $node_factory,
50 IconFactory $icon_factory,
51 array $sync_node_id_whitelist = [],
52 ?string $parent_id = null,
53 ): \Generator {
54 yield $node_factory->branch(
55 ['1'],
56 'branch node 1',
57 null,
58 $node_factory->branch(
59 ['1', '1.1'],
60 'branch node 1.1',
61 null,
62 $node_factory->leaf(['1', '1.1', '1.1.1'], 'leaf node 1.1.1'),
63 $node_factory->leaf(['1', '1.1', '1.1.2'], 'leaf node 1.1.2'),
64 ),
65 $node_factory->leaf(['1', '1.2'], 'leaf node 1.2'),
66 );
67 }
68
69 public function getNodesAsLeaf(
70 NodeFactory $node_factory,
71 IconFactory $icon_factory,
72 array $node_ids,
73 ): \Generator {
74 yield from [];
75 }
76 };
77
78 $input = $factory->input()->field()->treeMultiSelect(
79 $node_retrieval,
80 "select multiple nodes",
81 "you can also select child-nodes of selected nodes!",
82 );
83
84 $input = $input->withSelectChildNodes(true);
85
86 $form = $factory->input()->container()->form()->standard('#', [$input]);
87
88 return $renderer->render($form);
89}
$renderer
This is how a factory for icons looks like.
Definition: Factory.php:27
global $DIC
Definition: shib_login.php:26