ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
disabled.php File Reference

Go to the source code of this file.

Functions

 disabled ()
 Example showing how to plug a disabled radio into a form. More...
 

Function Documentation

◆ disabled()

disabled ( )

Example showing how to plug a disabled radio into a form.

Definition at line 5 of file disabled.php.

References $DIC, and $result.

6 {
7  //Step 0: Declare dependencies
8  global $DIC;
9  $ui = $DIC->ui()->factory();
10  $renderer = $DIC->ui()->renderer();
11  $request = $DIC->http()->request();
12 
13 
14  //Step 1: define the radio
15  $radio = $ui->input()->field()->radio("Radio", "Cannot check an option")
16  ->withOption('value1', 'label1')
17  ->withOption('value2', 'label2')
18  ->withOption('value3', 'label3')
19  ->withDisabled(true);
20 
21 
22  //Step 2: define form and form actions
23  $form = $ui->input()->container()->form()->standard('#', ['radio' => $radio]);
24 
25  //Step 3: implement some form data processing. Note, the value of the checkbox will
26  // be 'checked' if checked and null if unchecked.
27  if ($request->getMethod() == "POST") {
28  $form = $form->withRequest($request);
29  $result = $form->getData();
30  } else {
31  $result = "No result yet.";
32  }
33 
34  //Step 4: Render the radio with the enclosing form.
35  return
36  "<pre>" . print_r($result, true) . "</pre><br/>" .
37  $renderer->render($form);
38 }
$result
$DIC
Definition: xapitoken.php:46