ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
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 
24 
40 function base()
41 {
42  global $DIC;
43  $ui = $DIC->ui()->factory();
44  $renderer = $DIC->ui()->renderer();
45  $request = $DIC->http()->request();
46 
47  $txt = "This allows for a preceding text and longer questions to ask.";
48 
49  $rating = $ui->input()->field()->rating("Rate with the Stars:", "change the rating")
50  ->withAdditionalText($txt)
51  ->withValue(FiveStarRatingScale::AVERAGE);
52  $rating_required = $ui->input()->field()->rating("Rate with the Stars:", 'this is required')
53  ->withRequired(true);
54  $rating_disabled = $ui->input()->field()->rating("Rate with the Stars:", "this is disabled")
55  ->withValue(FiveStarRatingScale::BAD)
56  ->withDisabled(true);
57  $rating_average = $ui->input()->field()->rating("Follow the Stars:", "the little line above shows the current average")
58  ->withValue(FiveStarRatingScale::TERRIBLE)
59  ->withCurrentAverage(3.5);
60 
61 
62  $form = $ui->input()->container()->form()
63  ->standard('#', [
64  'rating_1' => $rating,
65  'rating_2' => $rating_required,
66  'rating_3' => $rating_disabled,
67  'rating_4' => $rating_average
68  ]);
69 
70  if ($request->getMethod() == "POST") {
71  $form = $form->withRequest($request);
72  $result = $form->getData();
73  } else {
74  $result = "No result yet.";
75  }
76 
77  return
78  "<pre>" . print_r($result, true) . "</pre><br/>" .
79  $renderer->render($form);
80 }
$renderer
FiveStarRatingScale
This is the scale for the Rating Input.
base()
description: > Base example showing how use a Rating Input.
Definition: base.php:40
global $DIC
Definition: shib_login.php:22
$txt
Definition: error.php:31