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 
44 function base()
45 {
46  //declare dependencies
47  global $DIC;
48  $ui = $DIC->ui()->factory();
49  $renderer = $DIC->ui()->renderer();
50  $request = $DIC->http()->request();
51 
52  //define options.
53  $options = array(
54  "1" => "Pick 1",
55  "2" => "Pick 2",
56  "3" => "Pick 3",
57  "4" => "Pick 4",
58  );
59 
60  //define the select
61  $multi = $ui->input()->field()->multiselect("Take your picks", $options, "This is the byline text")
62  ->withRequired(true);
63 
64  //define form and form actions
65  $form = $ui->input()->container()->form()->standard('#', ['multi' => $multi]);
66 
67 
68  //implement some form data processing.
69  if ($request->getMethod() == "POST") {
70  try {
71  $form = $form->withRequest($request);
72  $result = $form->getData();
73  } catch (\InvalidArgumentException $e) {
74  $result = "No result. Probably, the other form was used.";
75  }
76  } else {
77  $result = "No result yet.";
78  }
79 
80  //render the select with the enclosing form.
81  return
82  "<pre>" . print_r($result, true) . "</pre><br/>" .
83  $renderer->render($form);
84 }
$renderer
base()
description: > Base example showing how to plug a Multi-Select into a form.
Definition: base.php:44
global $DIC
Definition: shib_login.php:22