ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
disabled.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
39 function disabled()
40 {
41  //Step 0: Declare dependencies
42  global $DIC;
43  $ui = $DIC->ui()->factory();
44  $renderer = $DIC->ui()->renderer();
45  $ctrl = $DIC->ctrl();
46  $request = $DIC->http()->request();
47 
48  //Step 1: Define the textarea input field
49  $textarea_input = $ui->input()->field()->textarea("Disabled Textarea Input", "Just a disabled textarea input.")
50  ->withDisabled(true);
51 
52  //Step 2: Define the form action to target the input processing
53  $DIC->ctrl()->setParameterByClass(
54  'ilsystemstyledocumentationgui',
55  'example_name',
56  'disabled'
57  );
58  $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
59 
60  //Step 3: Define the form and form actions.
61  $form = $ui->input()->container()->form()->standard($form_action, [$textarea_input]);
62 
63  //Step 4: implement some form data processing.
64  if ($request->getMethod() == "POST" && $request->getQueryParams()['example_name'] == 'disabled') {
65  $form = $form->withRequest($request);
66  $result = $form->getData();
67  } else {
68  $result = "No result yet.";
69  }
70 
71  //Step 5: Render the form with the text input field
72  return
73  "<pre>" . print_r($result, true) . "</pre><br/>" .
74  $renderer->render($form);
75 }
disabled()
description: > Example shows how to create and render a disabled textarea field and attach it to a f...
Definition: disabled.php:39
$renderer
global $DIC
Definition: shib_login.php:22