ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
base.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
26 function base()
27 {
28  //Step 1: Declare dependencies
29  global $DIC;
30  $ui = $DIC->ui()->factory();
31  $renderer = $DIC->ui()->renderer();
32  $request = $DIC->http()->request();
33 
34  //Step 2: define the radio with options
35  $radio = $ui->input()->field()->radio("Radio", "check an option")
36  ->withOption('value1', 'label1', 'byline1')
37  ->withOption('10', 'numeric value (ten)', 'byline2')
38  ->withOption('030', 'not-numeric value', 'byline3');
39 
40  //Step 3: define form and form actions
41  $form = $ui->input()->container()->form()->standard('#', ['radio' => $radio]);
42 
43  //Step 4: implement some form data processing.
44  if ($request->getMethod() == "POST") {
45  $form = $form->withRequest($request);
46  $result = $form->getData();
47  } else {
48  $result = "No result yet.";
49  }
50 
51  //Step 5: Render the radio with the enclosing form.
52  return
53  "<pre>" . print_r($result, true) . "</pre><br/>" .
54  $renderer->render($form);
55 }
$renderer
global $DIC
Definition: shib_login.php:25
base()
description: > Base example showing how to plug a radio into a form
Definition: base.php:26