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

Go to the source code of this file.

Functions

 base ()
 Example show how to create and render a basic textarea field and attach it to a form. More...
 

Function Documentation

◆ base()

base ( )

Example show how to create and render a basic textarea field and attach it to a form.

Definition at line 6 of file base.php.

References $DIC, $form, $request, and $result.

7 {
8  //Step 0: Declare dependencies
9  global $DIC;
10  $ui = $DIC->ui()->factory();
11  $renderer = $DIC->ui()->renderer();
12  $ctrl = $DIC->ctrl();
13  $request = $DIC->http()->request();
14 
15  //Step 1: Define the textarea input field
16  $textarea_input = $ui->input()->field()->textarea("Textarea Input", "Just a textarea input.");
17 
18  //Step 2: Define the form and form actions.
19  $ctrl->setParameterByClass(
20  'ilsystemstyledocumentationgui',
21  'example_name',
22  'textarea'
23  );
24  $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
25  $form = $ui->input()->container()->form()->standard($form_action, [$textarea_input]);
26 
27  //Step 3: implement some form data processing.
28  if ($request->getMethod() == "POST"
29  && $request->getQueryParams()['example_name'] == "textarea") {
30  $form = $form->withRequest($request);
31  $result = $form->getData();
32  } else {
33  $result = "No result yet.";
34  }
35 
36  //Step 4: Render the form with the text input field
37  return
38  "<pre>" . print_r($result, true) . "</pre><br/>" .
39  $renderer->render($form);
40 }
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
global $DIC
Definition: saml.php:7
if(isset($_POST['submit'])) $form