ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
with_required_sub_inputs.php File Reference

Go to the source code of this file.

Functions

 with_required_sub_inputs ()
 Example showing how an optional group (of inputs) which shows, that the optional input will not be required even though it's sub inputs are. More...
 

Function Documentation

◆ with_required_sub_inputs()

with_required_sub_inputs ( )

Example showing how an optional group (of inputs) which shows, that the optional input will not be required even though it's sub inputs are.

Definition at line 8 of file with_required_sub_inputs.php.

References $DIC, $factory, and $result.

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
global $DIC
Definition: goto.php:24
$factory
Definition: metadata.php:58