3 declare(strict_types=1);
24 $ui = $DIC->ui()->factory();
27 $request = $DIC->http()->request();
31 $text_input = $ui->input()->field()->text(
"Enter a name",
"Needs to start with an H");
32 $custom_constraint =
$refinery->custom()->constraint(
function ($value) {
33 return (substr($value, 0, 1) ===
'H') ?
true :
false;
34 },
"Name does not start with an H");
35 $text_input = $text_input->withRequired(
true, $custom_constraint);
38 $form = $ui->input()->container()->form()->standard(
'#', [ $text_input]);
41 if ($request->getMethod() ==
"POST") {
42 $form = $form->withRequest($request);
43 $result = $form->getData();
45 $result =
"No result yet.";
50 "<pre>" . print_r($result,
true) .
"</pre><br/>" .