Revision #213 has been created by rackycz on Jul 13, 2020, 1:54:31 PM with the memo:
Grid layout + helpers
« previous (#212) next (#214) »
Changes
Title
unchanged
Yii v2 snippet guide
Category
unchanged
Tutorials
Yii version
unchanged
2.0
Tags
unchanged
tutorial,beginner,yii2
Content
changed
[...]
// filterSelector is the core solution of this problem. It refreshes the grid.
```
**Creating your new helper class**
---
Sometimes you need a static class that will do things for you. This is what helpers do.
I work with the Basic example so I do things like this:
- Create folder named "myHelpers" next to the folder "controller
s"
- Place there your class and do not forget about the "namespace":[...]
```
- If you want to use the class, do not forget to include the file:
```php
use myHelpers\MyClassName;
```
- And now you can use the any method. For example this static method:
```php// ...
echo MyClassName::myMethod(123);
```[...]
The result is that your form has 3 rows, the middle one is empty. In the first row there are 3 cells (username, nothing, email) and in the last row there is 2x password.
You do not have to write any HTML, you only arrange inputs into any number of rows and columns (using the array $gridForm) and things just happen automagically.