ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
base.php
Go to the documentation of this file.
1<?php
5function base()
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 dependant fields
15 $dependant_field1 = $ui->input()->field()->text("Item 1", "Just some dependent group field");
16 $dependant_field2 = $ui->input()->field()->text("Item 2", "Just some dependent group field");
17 $dependant_fields = [
18 "dependant_field_a" => $dependant_field1,
19 "dependant_field_b" => $dependant_field2
20 ];
21
22 $radio_d = $ui->input()->field()->radio("Dep. Radio", "check an option")
23 ->withOption('value1', 'label1', 'byline1')
24 ->withOption('value2', 'label2', 'byline2', $dependant_fields);
25
26 $radio_num_value = $ui->input()->field()->radio("Numeric Values", "pick one...")
27 ->withOption('1', 'One', '')
28 ->withOption('2', 'Two', '')
29 ->withOption('3', 'Three', '');
30
31 //Step 2: define the radio
32 $radio = $ui->input()->field()->radio("Radio", "check an option")
33 ->withOption('value1', 'label1', 'byline1')
34 ->withOption('value2', 'label2', 'byline2', $dependant_fields)
35 ->withOption('value3', 'label3', 'byline3', [$radio_d])
36 ->withOption('value4', 'numerics', 'test num values', [$radio_num_value]);
37
38
39 //Step 3: define form and form actions
40 $DIC->ctrl()->setParameterByClass(
41 'ilsystemstyledocumentationgui',
42 'example_name',
43 'radio'
44 );
45 $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
46 $form = $ui->input()->container()->form()->standard('#', ['radio' => $radio]);
47
48 //Step 4: implement some form data processing. Note, the value of the checkbox will
49 // be 'checked' if checked an null if unchecked.
50 if ($request->getMethod() == "POST") {
51 $form = $form->withRequest($request);
52 $result = $form->getData();
53 } else {
54 $result = "No result yet.";
55 }
56
57 //Step 5: Render the radio with the enclosing form.
58 return
59 "<pre>" . print_r($result, true) . "</pre><br/>" .
60 $renderer->render($form);
61}
base()
Definition: base.php:2
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7