ILIAS  release_8 Revision v8.24
base.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
11function base()
12{
13 //Step 0: Declare dependencies
14 global $DIC;
15 $ui = $DIC->ui()->factory();
16 $request = $DIC->http()->request();
17 $renderer = $DIC->ui()->renderer();
18
19 //Step 1: Define the textarea input field
20 $textarea_input = $ui->input()->field()->textarea("Textarea Input", "Just a textarea input.");
21
22 //Step 2: Define the form action to target the input processing
23 $DIC->ctrl()->setParameterByClass(
24 'ilsystemstyledocumentationgui',
25 'example_name',
26 'base'
27 );
28 $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
29
30 //Step 3: Define the form and form actions.
31 $form = $ui->input()->container()->form()->standard($form_action, [$textarea_input]);
32
33 //Step 4: Define some data processing.
34 if ($request->getMethod() == "POST" && $request->getQueryParams()['example_name'] == 'base') {
35 $form = $form->withRequest($request);
36 $result = $form->getData();
37 } else {
38 $result = "No result yet.";
39 }
40
41 //Step 5: Render the form with the text input field
42 return
43 "<pre>" . print_r($result, true) . "</pre><br/>" .
44 $renderer->render($form);
45}
global $DIC
Definition: feed.php:28
base()
Example show how to create and render a basic textarea field and attach it to a form.
Definition: base.php:11