ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
base.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
42 function base()
43 {
44  //Step 1: Declare dependencies
45  global $DIC;
46  $ui = $DIC->ui()->factory();
47  $renderer = $DIC->ui()->renderer();
48  $request = $DIC->http()->request();
49 
50  //Step 2: define the radio with options
51  $radio = $ui->input()->field()->radio("Radio", "check an option")
52  ->withOption('value1', 'label1', 'byline1')
53  ->withOption('10', 'numeric value (ten)', 'byline2')
54  ->withOption('030', 'not-numeric value', 'byline3');
55 
56  //Step 3: define form and form actions
57  $form = $ui->input()->container()->form()->standard('#', ['radio' => $radio]);
58 
59  //Step 4: implement some form data processing.
60  if ($request->getMethod() == "POST") {
61  $form = $form->withRequest($request);
62  $result = $form->getData();
63  } else {
64  $result = "No result yet.";
65  }
66 
67  //Step 5: Render the radio with the enclosing form.
68  return
69  "<pre>" . print_r($result, true) . "</pre><br/>" .
70  $renderer->render($form);
71 }
$renderer
global $DIC
Definition: shib_login.php:22
base()
description: > Base example showing how to plug a radio into a form
Definition: base.php:42