ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
with_value.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
21
33function with_value(): string
34{
35 global $DIC;
36 $factory = $DIC->ui()->factory();
37 $renderer = $DIC->ui()->renderer();
38
39 $group_one = $factory->input()->field()->group([$factory->input()->field()->text("Item 1", "Just some field")], "Group 1");
40 $group_two = $factory->input()->field()->group([$factory->input()->field()->text("Item 2", "Just some field")], "Group 2");
41
42 $switchable_group = $factory->input()->field()->switchableGroup(
43 [$group_one, $group_two],
44 "Switchable Group with existing value(s)",
45 );
46
47 // tells the input only which option is selected
48 $direct_value = $switchable_group->withValue(1);
49
50 // tells the input which option is selected and what value(s) it has
51 $nested_value = $switchable_group->withValue([1, ['some existing text value']]);
52
53 $form = $factory->input()->container()->form()->standard('#', [$direct_value, $nested_value]);
54
55 return $renderer->render($form);
56}
$renderer
global $DIC
Definition: shib_login.php:26