ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
with_required.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
11
24function with_required(): string
25{
26 global $DIC;
27
28 $factory = $DIC->ui()->factory();
29 $renderer = $DIC->ui()->renderer();
30
31 $node_retrieval = new class () implements NodeRetrieval {
32 public function getNodes(
33 NodeFactory $node_factory,
34 IconFactory $icon_factory,
35 ?string $parent_id = null,
36 ): \Generator {
37 yield from [];
38 }
39 public function getNodesAsLeaf(
40 NodeFactory $node_factory,
41 IconFactory $icon_factory,
42 array $node_ids,
43 ): \Generator {
44 yield from [];
45 }
46 };
47
48 $input = $factory->input()->field()->treeSelect(
49 $node_retrieval,
50 "select a single node",
51 "this field should be marked as required.",
52 );
53
54 $input = $input->withRequired(true);
55
56 $form = $factory->input()->container()->form()->standard('#', [$input]);
57
58 return $renderer->render($form);
59}
$renderer
This is how a factory for icons looks like.
Definition: Factory.php:27
global $DIC
Definition: shib_login.php:26