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