ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
base.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
23 function base()
24 {
25  //Step 0: Declare dependencies
26  global $DIC;
27  $ui = $DIC->ui()->factory();
28  $request = $DIC->http()->request();
29  $renderer = $DIC->ui()->renderer();
30 
31  //Step 1: Define the textarea input field
32  $textarea_input = $ui->input()->field()->textarea("Textarea Input", "Just a textarea input.");
33 
34  //Step 2: Define the form action to target the input processing
35  $DIC->ctrl()->setParameterByClass(
36  'ilsystemstyledocumentationgui',
37  'example_name',
38  'base'
39  );
40  $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
41 
42  //Step 3: Define the form and form actions.
43  $form = $ui->input()->container()->form()->standard($form_action, [$textarea_input]);
44 
45  //Step 4: Define some data processing.
46  if ($request->getMethod() == "POST" && $request->getQueryParams()['example_name'] == 'base') {
47  $form = $form->withRequest($request);
48  $result = $form->getData();
49  } else {
50  $result = "No result yet.";
51  }
52 
53  //Step 5: Render the form with the text input field
54  return
55  "<pre>" . print_r($result, true) . "</pre><br/>" .
56  $renderer->render($form);
57 }
$renderer
global $DIC
Definition: shib_login.php:25
base()
description: > The example shows how to create and render a basic textarea field and attach it to a ...
Definition: base.php:23