ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
with_select_child_nodes.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
11
25function with_select_child_nodes(): string
26{
27 global $DIC;
28
29 $factory = $DIC->ui()->factory();
30 $renderer = $DIC->ui()->renderer();
31
32 $node_retrieval = new class () implements NodeRetrieval {
33 public function getNodes(
34 NodeFactory $node_factory,
35 IconFactory $icon_factory,
36 ?string $parent_id = null,
37 ): \Generator {
38 yield $node_factory->branch('1', 'branch node 1', null,
39 $node_factory->branch('1.1', 'branch node 1.1', null,
40 $node_factory->leaf('1.1.1', 'leaf node 1.1.1'),
41 $node_factory->leaf('1.1.2', 'leaf node 1.1.2'),
42 ),
43 $node_factory->leaf('1.2', 'leaf node 1.2'),
44 );
45 }
46 public function getNodesAsLeaf(
47 NodeFactory $node_factory,
48 IconFactory $icon_factory,
49 array $node_ids,
50 ): \Generator {
51 yield from [];
52 }
53 };
54
55 $input = $factory->input()->field()->treeMultiSelect(
56 $node_retrieval,
57 "select multiple nodes",
58 "you can also select child-nodes of selected nodes!",
59 );
60
61 $input = $input->withSelectChildNodes(true);
62
63 $form = $factory->input()->container()->form()->standard('#', [$input]);
64
65 return $renderer->render($form);
66}
$renderer
This is how a factory for icons looks like.
Definition: Factory.php:27
global $DIC
Definition: shib_login.php:26