ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
with_required_input.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
36{
37 global $DIC;
38 $ui = $DIC->ui()->factory();
39 $renderer = $DIC->ui()->renderer();
40 $request = $DIC->http()->request();
41
42 $text_input = $ui->input()->field()
43 ->text("Required Input", "User needs to fill this field")
44 ->withRequired(true);
45
46 $section = $ui->input()->field()->section(
47 [$text_input],
48 "Section with required field",
49 "The Form should show an explaining hint at the bottom"
50 );
51
52 $DIC->ctrl()->setParameterByClass(
53 'ilsystemstyledocumentationgui',
54 'example_name',
55 'required'
56 );
57 $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
58
59 $form = $ui->input()->container()->form()->standard($form_action, [$section]);
60
61 if ($request->getMethod() == "POST"
62 && array_key_exists('example_name', $request->getQueryParams())
63 && $request->getQueryParams()['example_name'] == 'required') {
64 $form = $form->withRequest($request);
65 $result = $form->getData();
66 } else {
67 $result = "No result yet.";
68 }
69
70 return
71 "<pre>" . print_r($result, true) . "</pre><br/>" .
72 $renderer->render($form);
73}
$renderer
global $DIC
Definition: shib_login.php:26