ILIAS  trunk Revision v11.0_alpha-1846-g895b5f47236
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
disabled.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
32 function disabled()
33 {
34  //Step 0: Declare dependencies
35  global $DIC;
36 
37  $ui = $DIC->ui()->factory();
38  $renderer = $DIC->ui()->renderer();
39  $request = $DIC->http()->request();
40  $ctrl = $DIC->ctrl();
41 
42  //Define the options.
43  $options = array(
44  "1" => "Type 1",
45  "2" => "Type 2",
46  "3" => "Type 3",
47  "4" => "Type 4",
48  );
49 
50  //Step 1: define the select
51  $select = $ui->input()->field()->select("Cannot choose an Option", $options, "This is the byline text")
52  ->withDisabled(true);
53 
54  //Step 2: define form and form actions
55  $form = $ui->input()->container()->form()->standard('#', [$select]);
56 
57  //Step 3: implement some form data processing.
58  if ($request->getMethod() == "POST") {
59  $form = $form->withRequest($request);
60  $result = $form->getData();
61  } else {
62  $result = "No result yet.";
63  }
64 
65  //Step 4: Render the select with the enclosing form.
66  return
67  "<pre>" . print_r($result, true) . "</pre><br/>" .
68  $renderer->render($form);
69 }
$renderer
disabled()
description: > Example showing how to plug a disabled Select into a form
Definition: disabled.php:32
global $DIC
Definition: shib_login.php:22