ILIAS  release_7 Revision v7.30-3-g800a261c036
disabled.php
Go to the documentation of this file.
1<?php
6function disabled()
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}
disabled()
Example showing how to plug a disabled checkbox into a form.
Definition: disabled.php:5
$result
An exception for terminatinating execution or to throw for unit testing.
global $DIC
Definition: goto.php:24