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