@@ -41,6 +41,13 @@ The `EchoForm` class has `$message` property and related getter.
4141## Using the form <span id =" using-form " ></span >
4242
4343Now, that you have a form, use it in your action from "[ Saying Hello] ( hello.md ) ".
44+
45+ You also need to install hydrator package
46+
47+ ```
48+ composer require yiisoft/hydrator
49+ ```
50+
4451Here's what you end up with in ` /src/Controller/EchoController.php ` :
4552
4653``` php
@@ -51,7 +58,7 @@ declare(strict_types=1);
5158namespace App\Controller;
5259
5360use App\Form\EchoForm;
54- use Yiisoft\Yii\View\ViewRenderer;
61+ use Yiisoft\Yii\View\Renderer\ ViewRenderer;
5562use Psr\Http\Message\ResponseInterface;
5663use Psr\Http\Message\ServerRequestInterface;
5764use Yiisoft\Hydrator\Hydrator;
@@ -139,7 +146,7 @@ use Yiisoft\Html\Html;
139146
140147<?= Html::submitButton('Say') ?>
141148
142- <?= '</ form >' ?>
149+ <?= Html:: form()->close() ?>
143150```
144151
145152If a form has a message set, you're displaying a box with the message. The rest if about rendering the form.
@@ -215,7 +222,7 @@ use Psr\Http\Message\ResponseInterface;
215222use Psr\Http\Message\ServerRequestInterface;
216223use Yiisoft\Http\Method;
217224use Yiisoft\Validator\Validator;
218- use Yiisoft\Yii\View\ViewRenderer;
225+ use Yiisoft\Yii\View\Renderer\ ViewRenderer;
219226use Yiisoft\Hydrator\Hydrator;
220227
221228class EchoController
@@ -267,6 +274,11 @@ class EchoForm
267274 {
268275 return $this->message;
269276 }
277+
278+ public function getFormName()
279+ {
280+ return (new \ReflectionClass($this))->getShortName();
281+ }
270282
271283}
272284```
@@ -301,7 +313,7 @@ use Yiisoft\Html\Html;
301313<?php endif ?>
302314
303315<?= Html::form()
304- ->post($urlGenerator->generate('print/form '))
316+ ->post($urlGenerator->generate('echo/say '))
305317 ->csrf($csrf)
306318 ->open() ?>
307319
@@ -315,7 +327,7 @@ use Yiisoft\Html\Html;
315327
316328<?= Html::submitButton('Say') ?>
317329
318- <?= '</ form >' ?>
330+ <?= Html:: form()->close() ?>
319331```
320332
321333## Trying it Out <span id =" trying-it-out " ></span >
0 commit comments