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