ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
with_value.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
11 
24 function with_value(): 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  foreach ($node_ids as $node_id) {
45  yield $node_factory->leaf($node_id, "dummy leaf node $node_id");
46  }
47  }
48  };
49 
50  $input = $factory->input()->field()->treeMultiSelect(
51  $node_retrieval,
52  "select multiple nodes",
53  "there should already be a minor selection.",
54  );
55 
56  $input = $input->withValue(['1.2', '2.3', '3.1']);
57 
58  $form = $factory->input()->container()->form()->standard('#', [$input]);
59 
60  return $renderer->render($form);
61 }
$renderer
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This is how a factory for icons looks like.
Definition: Factory.php:26
with_value()
description: > The example shows how to provide a Tree Multi Select Field with existing values...
Definition: with_value.php:24
global $DIC
Definition: shib_login.php:26