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
13 //Step 0: Declare dependencies
14 global $DIC;
15
16 $ui = $DIC->ui()->factory();
17 $renderer = $DIC->ui()->renderer();
18 $request = $DIC->http()->request();
19 $ctrl = $DIC->ctrl();
20
21 //Define the options.
22 $options = array(
23 "1" => "Type 1",
24 "2" => "Type 2",
25 "3" => "Type 3",
26 "4" => "Type 4",
27 );
28
29 //Step 1: define the select
30 $select = $ui->input()->field()->select("Cannot choose an Option", $options, "This is the byline text")
31 ->withDisabled(true);
32
33 //Step 2: define form and form actions
34 $form = $ui->input()->container()->form()->standard('#', [$select]);
35
36 //Step 3: implement some form data processing.
37 if ($request->getMethod() == "POST") {
38 $form = $form->withRequest($request);
39 $result = $form->getData();
40 } else {
41 $result = "No result yet.";
42 }
43
44 //Step 4: Render the select with the enclosing form.
45 return
46 "<pre>" . print_r($result, true) . "</pre><br/>" .
47 $renderer->render($form);
48}
global $DIC
Definition: feed.php:28
disabled()
Example showing how to plug a disabled Select into a form.
Definition: disabled.php:10