ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
with_limits.php
Go to the documentation of this file.
1 <?php
6 function with_limits()
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  $min_limit = 3;
16  $max_limit = 20;
17 
18  //Step 1: Define the textarea input field
19  $textarea_input = $ui->input()->field()->textarea("Textarea Input", "Just a textarea input.")->withMinLimit($min_limit)->withMaxLimit($max_limit);
20 
21  //Step 2: Define the form and form actions.
22  $ctrl->setParameterByClass(
23  'ilsystemstyledocumentationgui',
24  'example_name_limited',
25  'textarea_limited'
26  );
27  $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
28  $form = $ui->input()->container()->form()->standard($form_action, [$textarea_input]);
29 
30  //Step 3: implement some form data processing.
31  if ($request->getMethod() == "POST"
32  && $request->getQueryParams()['example_name_limited'] == "textarea_limited") {
33  $form = $form->withRequest($request);
34  $result = $form->getData();
35  } else {
36  $result = "No result yet.";
37  }
38 
39  //Step 4: Render the form with the text input field
40  return
41  "<pre>" . print_r($result, true) . "</pre><br/>" .
42  $renderer->render($form);
43 }
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
global $DIC
Definition: saml.php:7
with_limits()
This example shows how to create and render a basic textarea field with minimum and maximum number of...
Definition: with_limits.php:6
if(isset($_POST['submit'])) $form