ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
with_required.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
21
26
39function with_required(): string
40{
41 global $DIC;
42
43 $factory = $DIC->ui()->factory();
44 $renderer = $DIC->ui()->renderer();
45
46 $node_retrieval = new class () implements NodeRetrieval {
47 public function getNodes(
48 NodeFactory $node_factory,
49 IconFactory $icon_factory,
50 array $sync_node_id_whitelist = [],
51 ?string $parent_id = null,
52 ): \Generator {
53 yield from [];
54 }
55 public function getNodesAsLeaf(
56 NodeFactory $node_factory,
57 IconFactory $icon_factory,
58 array $node_ids,
59 ): \Generator {
60 yield from [];
61 }
62 };
63
64 $input = $factory->input()->field()->treeSelect(
65 $node_retrieval,
66 "select a single node",
67 "this field should be marked as required.",
68 );
69
70 $input = $input->withRequired(true);
71
72 $form = $factory->input()->container()->form()->standard('#', [$input]);
73
74 return $renderer->render($form);
75}
$renderer
This is how a factory for icons looks like.
Definition: Factory.php:27
global $DIC
Definition: shib_login.php:26