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