ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
base.php File Reference

Go to the source code of this file.

Functions

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

Function Documentation

◆ base()

base ( )

Base example showing how to plug a Multi-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" => "Pick 1",
19 "2" => "Pick 2",
20 "3" => "Pick 3",
21 "4" => "Pick 4",
22 );
23
24 //Step 1: define the select
25 $multi = $ui->input()->field()->multiselect("Take your picks", $options, "This is the byline text")
26 ->withRequired(true);
27
28 //Step 2: define form and form actions
29 $ctrl->setParameterByClass(
30 'ilsystemstyledocumentationgui',
31 'example_name_required',
32 'multiselect'
33 );
34 $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
35 $form = $ui->input()->container()->form()->standard($form_action, ['multi' => $multi]);
36
37 //Step 3: implement some form data processing.
38 if ($request->getMethod() == "POST"
39 && $request->getQueryParams()['example_name_required'] == "multiselect") {
40 $form = $form->withRequest($request);
41 $result = $form->getData();
42 } else {
43 $result = "No result yet.";
44 }
45
46 //Step 4: Render the select with the enclosing form.
47 return
48 "<pre>" . print_r($result, true) . "</pre><br/>" .
49 $renderer->render($form);
50}
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7

References $DIC, $form, PHPMailer\PHPMailer\$options, $request, and $result.