ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
reduce_with.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
37function reduce_with()
38{
39 global $DIC;
40 $ui = $DIC->ui()->factory();
41 $renderer = $DIC->ui()->renderer();
42
43 $text_input = $ui->input()->field()
44 ->text("Required Input", "User needs to fill this field")
45 ->withRequired(true);
46
47 $section = $ui->input()->field()->section(
48 [$text_input],
49 "Section with required field",
50 "The Form should show an explaining hint at the bottom"
51 );
52
53 $form = $ui->input()->container()->form()->standard("", [$section, $section, $text_input]);
54
55 $array = $form->reduceWith(
56 fn($c, $res) => [$c->getCanonicalName() => $res]
57 );
58
59 return $renderer->render([
60 $ui->legacy()->content('<pre>' . print_r(json_encode($array, JSON_PRETTY_PRINT), true) . '</pre>'),
61 ]);
62}
$renderer
$c
Definition: deliver.php:25
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26