ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
disabled.php File Reference

Go to the source code of this file.

Functions

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

Function Documentation

◆ disabled()

disabled ( )

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

Definition at line 6 of file disabled.php.

References $DIC, 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("Disabled Textarea Input", "Just a disabled textarea input.")
17  ->withDisabled(true);
18 
19  //Step 2: Define the form action to target the input processing
20  $DIC->ctrl()->setParameterByClass(
21  'ilsystemstyledocumentationgui',
22  'example_name',
23  'disabled'
24  );
25  $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
26 
27  //Step 3: Define the form and form actions.
28  $form = $ui->input()->container()->form()->standard($form_action, [$textarea_input]);
29 
30  //Step 4: implement some form data processing.
31  if ($request->getMethod() == "POST" && $request->getQueryParams()['example_name'] == 'disabled') {
32  $form = $form->withRequest($request);
33  $result = $form->getData();
34  } else {
35  $result = "No result yet.";
36  }
37 
38  //Step 5: Render the form with the text input field
39  return
40  "<pre>" . print_r($result, true) . "</pre><br/>" .
41  $renderer->render($form);
42 }
$result
global $DIC
Definition: goto.php:24