Skip to content

Commit 23f0b9d

Browse files
authored
Modify the ViewRenderer use statement, add hydrator install guidance and etc (#227)
1 parent b0d8e6c commit 23f0b9d

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

guide/en/start/forms.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ The `EchoForm` class has `$message` property and related getter.
4141
## Using the form <span id="using-form"></span>
4242

4343
Now, 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+
4451
Here's what you end up with in `/src/Controller/EchoController.php`:
4552

4653
```php
@@ -51,7 +58,7 @@ declare(strict_types=1);
5158
namespace App\Controller;
5259

5360
use App\Form\EchoForm;
54-
use Yiisoft\Yii\View\ViewRenderer;
61+
use Yiisoft\Yii\View\Renderer\ViewRenderer;
5562
use Psr\Http\Message\ResponseInterface;
5663
use Psr\Http\Message\ServerRequestInterface;
5764
use 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

145152
If 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;
215222
use Psr\Http\Message\ServerRequestInterface;
216223
use Yiisoft\Http\Method;
217224
use Yiisoft\Validator\Validator;
218-
use Yiisoft\Yii\View\ViewRenderer;
225+
use Yiisoft\Yii\View\Renderer\ViewRenderer;
219226
use Yiisoft\Hydrator\Hydrator;
220227

221228
class 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>

guide/en/start/hello.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ declare(strict_types=1);
134134

135135
namespace App\Controller;
136136

137-
use Yiisoft\Yii\View\ViewRenderer;
137+
use Yiisoft\Yii\View\Renderer\ViewRenderer;
138138
use Yiisoft\Router\CurrentRoute;
139139
use Psr\Http\Message\ResponseInterface;
140140

0 commit comments

Comments
 (0)