M
M
Messi2017-09-02 11:27:05
Yii
Messi, 2017-09-02 11:27:05

What is the best way to organize a page with different forms?

There are users with different types in the table (Driver, Passenger, Pedestrian).
There is a Users class with methods
- the create method (users and their type are created here)
- the update method (data about users are updated
) is this correct to implement?
As I see it:
In the update method, accept the id of the updated user, then get the type.
In Switch, get the type and, depending on the type, transfer to render('update') the loading of the _formDriver.php block, and so on.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-09-02
@FitTech

and not easier to make a name for the view with a type id and do just:

$view_name = '_user_view_type_'.$model->type;
return $this->render($view_name,['model'=>$model]);

Even if there are other manipulations, it is better to bring them into the model.

M
Maxim Fedorov, 2017-09-02
@Maksclub

a little aside
You'd better make 1 more table Profile for example - there will be data about users (names, positions, etc.), in the User table only passwords and logins
https://yiiframework.com.ua/en/doc/guide/2 /input-m...
Well, yes, that's right -- Let ProfileFormService render the desired form, pass it to the
renderer Everything else can be done through roles in RBAC

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question