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