ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
disabled.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
21 function disabled()
22 {
23  //Step 0: Declare dependencies
24  global $DIC;
25  $ui = $DIC->ui()->factory();
26  $renderer = $DIC->ui()->renderer();
27  $request = $DIC->http()->request();
28 
29 
30  //Step 1: define the radio
31  $radio = $ui->input()->field()->radio("Radio", "Cannot check an option")
32  ->withOption('value1', 'label1')
33  ->withOption('value2', 'label2')
34  ->withOption('value3', 'label3')
35  ->withDisabled(true);
36 
37 
38  //Step 2: define form and form actions
39  $form = $ui->input()->container()->form()->standard('#', ['radio' => $radio]);
40 
41  //Step 3: implement some form data processing. Note, the value of the checkbox will
42  // be 'checked' if checked and null if unchecked.
43  if ($request->getMethod() == "POST") {
44  $form = $form->withRequest($request);
45  $result = $form->getData();
46  } else {
47  $result = "No result yet.";
48  }
49 
50  //Step 4: Render the radio with the enclosing form.
51  return
52  "<pre>" . print_r($result, true) . "</pre><br/>" .
53  $renderer->render($form);
54 }
$renderer
disabled()
description: > Example showing how to plug a disabled radio into a form
Definition: disabled.php:21
global $DIC
Definition: shib_login.php:25