ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
with_required_sub_inputs.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
41{
42 global $DIC;
43 $factory = $DIC->ui()->factory();
44 $renderer = $DIC->ui()->renderer();
45 $request = $DIC->http()->request();
46
47 $optional_group = $factory->input()->field()->optionalGroup([
48 $factory->input()->field()->text(
49 'this input is required',
50 'but only if the optional group is checked'
51 )->withRequired(true)
52 ], 'this input is not required');
53
54 $form = $factory->input()->container()->form()->standard('#', [$optional_group]);
55
56 if ("POST" === $request->getMethod()) {
57 $form = $form->withRequest($request);
58 $result = $form->getData();
59 } else {
60 $result = "No result yet.";
61 }
62
63 return "<pre>" . print_r($result, true) . "</pre>" . $renderer->render($form);
64}
$renderer
global $DIC
Definition: shib_login.php:26