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