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 
8 
24 function base()
25 {
26  global $DIC;
27  $ui = $DIC->ui()->factory();
28  $renderer = $DIC->ui()->renderer();
29  $request = $DIC->http()->request();
30 
31  $txt = "This allows for a preceding text and longer questions to ask.";
32 
33  $rating = $ui->input()->field()->rating("Rate with the Stars:", "change the rating")
34  ->withAdditionalText($txt)
35  ->withValue(FiveStarRatingScale::AVERAGE);
36  $rating_required = $ui->input()->field()->rating("Rate with the Stars:", 'this is required')
37  ->withRequired(true);
38  $rating_disabled = $ui->input()->field()->rating("Rate with the Stars:", "this is disabled")
39  ->withValue(FiveStarRatingScale::BAD)
40  ->withDisabled(true);
41  $rating_average = $ui->input()->field()->rating("Follow the Stars:", "the little line above shows the current average")
42  ->withValue(FiveStarRatingScale::TERRIBLE)
43  ->withCurrentAverage(3.5);
44 
45 
46  $form = $ui->input()->container()->form()
47  ->standard('#', [
48  'rating_1' => $rating,
49  'rating_2' => $rating_required,
50  'rating_3' => $rating_disabled,
51  'rating_4' => $rating_average
52  ]);
53 
54  if ($request->getMethod() == "POST") {
55  $form = $form->withRequest($request);
56  $result = $form->getData();
57  } else {
58  $result = "No result yet.";
59  }
60 
61  return
62  "<pre>" . print_r($result, true) . "</pre><br/>" .
63  $renderer->render($form);
64 }
$renderer
FiveStarRatingScale
This is the scale for the Rating Input.
base()
description: > Base example showing how use a Rating Input.
Definition: base.php:24
global $DIC
Definition: shib_login.php:25
$txt
Definition: error.php:30