3 declare(strict_types=1);
27 $ui = $DIC->ui()->factory();
29 $request = $DIC->http()->request();
31 $txt =
"This allows for a preceding text and longer questions to ask.";
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')
38 $rating_disabled = $ui->input()->field()->rating(
"Rate with the Stars:",
"this is disabled")
39 ->withValue(FiveStarRatingScale::BAD)
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);
46 $form = $ui->input()->container()->form()
48 'rating_1' => $rating,
49 'rating_2' => $rating_required,
50 'rating_3' => $rating_disabled,
51 'rating_4' => $rating_average
54 if ($request->getMethod() ==
"POST") {
55 $form = $form->withRequest($request);
56 $result = $form->getData();
58 $result =
"No result yet.";
62 "<pre>" . print_r($result,
true) .
"</pre><br/>" .
FiveStarRatingScale
This is the scale for the Rating Input.