ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
base.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
33function base()
34{
35 //Step 0: Declare dependencies
36 global $DIC;
37 $ui = $DIC->ui()->factory();
38 $renderer = $DIC->ui()->renderer();
39 $request = $DIC->http()->request();
40
41 //Step 1: define the checkbox, and turning it on
42 $checkbox_input = $ui->input()->field()->checkbox("Checkbox", "Check or not.")
43 ->withValue(true);
44
45 //Step 2: define form and form actions
46 $form = $ui->input()->container()->form()->standard('#', [ $checkbox_input]);
47
48 //Step 3: implement some form data processing. Note, the value of the checkbox will
49 // be 'checked' if checked an null if unchecked.
50 if ($request->getMethod() == "POST") {
51 $form = $form->withRequest($request);
52 $result = $form->getData();
53 } else {
54 $result = "No result yet.";
55 }
56
57 //Step 4: Render the checkbox with the enclosing form.
58 return
59 "<pre>" . print_r($result, true) . "</pre><br/>" .
60 $renderer->render($form);
61}
$renderer
global $DIC
Definition: shib_login.php:26