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