ILIAS  release_7 Revision v7.30-3-g800a261c036
with_required_sub_inputs.php
Go to the documentation of this file.
1<?php
2
9{
10 global $DIC;
11 $factory = $DIC->ui()->factory();
12 $renderer = $DIC->ui()->renderer();
13 $request = $DIC->http()->request();
14
15 $optional_group = $factory->input()->field()->optionalGroup([
16 $factory->input()->field()->text(
17 'this input is required',
18 'but only if the optional group is checked'
19 )->withRequired(true)
20 ], 'this input is not required');
21
22 $form = $factory->input()->container()->form()->standard('#', [$optional_group]);
23
24 if ("POST" === $request->getMethod()) {
25 $form = $form->withRequest($request);
26 $result = $form->getData();
27 } else {
28 $result = "No result yet.";
29 }
30
31 return "<pre>" . print_r($result, true) . "</pre>" . $renderer->render($form);
32}
$result
An exception for terminatinating execution or to throw for unit testing.
global $DIC
Definition: goto.php:24
$factory
Definition: metadata.php:58
with_required_sub_inputs()
Example showing how an optional group (of inputs) which shows, that the optional input will not be re...