ILIAS  release_8 Revision v8.24
disabled.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
10function disabled()
11{
12 //Step 0: Declare dependencies
13 global $DIC;
14 $ui = $DIC->ui()->factory();
15 $renderer = $DIC->ui()->renderer();
16 $request = $DIC->http()->request();
17
18
19 //Step 1: define the radio
20 $radio = $ui->input()->field()->radio("Radio", "Cannot check an option")
21 ->withOption('value1', 'label1')
22 ->withOption('value2', 'label2')
23 ->withOption('value3', 'label3')
24 ->withDisabled(true);
25
26
27 //Step 2: define form and form actions
28 $form = $ui->input()->container()->form()->standard('#', ['radio' => $radio]);
29
30 //Step 3: implement some form data processing. Note, the value of the checkbox will
31 // be 'checked' if checked and null if unchecked.
32 if ($request->getMethod() == "POST") {
33 $form = $form->withRequest($request);
34 $result = $form->getData();
35 } else {
36 $result = "No result yet.";
37 }
38
39 //Step 4: Render the radio with the enclosing form.
40 return
41 "<pre>" . print_r($result, true) . "</pre><br/>" .
42 $renderer->render($form);
43}
global $DIC
Definition: feed.php:28
disabled()
Example showing how to plug a disabled radio into a form.
Definition: disabled.php:10