Go to the source code of this file.
◆ with_required()
Base example showing how to plug a Select into a form.
Definition at line 5 of file with_required.php.
6{
7
8
10
11 $ui =
$DIC->ui()->factory();
12 $renderer =
$DIC->ui()->renderer();
13 $request =
$DIC->http()->request();
15
16
17 $options = array(
18 "1" => "Type 1",
19 "2" => "Type 2",
20 "3" => "Type 3",
21 "4" => "Type 4",
22 );
23
24
25 $select = $ui->input()->field()->select("Choose an Option", $options, "This is the byline text")->withRequired(true);
26
27
28 $form = $ui->input()->container()->form()->standard('#', [$select]);
29
30
31 if ($request->getMethod() == "POST") {
32 $form = $form->withRequest($request);
34 } else {
36 }
37
38
39 return
40 "<pre>" . print_r(
$result,
true) .
"</pre><br/>" .
41 $renderer->render($form);
42}
References $DIC, and $result.