ILIAS  release_7 Revision v7.30-3-g800a261c036
base.php File Reference

Go to the source code of this file.

Functions

 base ()
 Base example showing how to plug a Select into a form. More...
 

Function Documentation

◆ base()

base ( )

Base example showing how to plug a Select into a form.

Definition at line 5 of file base.php.

6{
7
8 //Step 0: Declare dependencies
9 global $DIC;
10
11 $ui = $DIC->ui()->factory();
12 $renderer = $DIC->ui()->renderer();
13 $request = $DIC->http()->request();
14 $ctrl = $DIC->ctrl();
15
16 //Define the options.
17 $options = array(
18 "1" => "Type 1",
19 "2" => "Type 2",
20 "3" => "Type 3",
21 "4" => "Type 4",
22 );
23
24 //Step 1: define the select
25 $select = $ui->input()->field()->select("Choose an Option", $options, "This is the byline text");
26
27 //Step 2: define form and form actions
28 $form = $ui->input()->container()->form()->standard('#', [$select]);
29
30 //Step 3: implement some form data processing.
31 if ($request->getMethod() == "POST") {
32 $form = $form->withRequest($request);
33 $result = $form->getData();
34 } else {
35 $result = "No result yet.";
36 }
37
38 //Step 4: Render the select with the enclosing form.
39 return
40 "<pre>" . print_r($result, true) . "</pre><br/>" .
41 $renderer->render($form);
42}
$result
global $DIC
Definition: goto.php:24

References $DIC, and $result.