A
A
AlikDex2016-08-08 18:33:16
Yii
AlikDex, 2016-08-08 18:33:16

Yii2 from widget to base, right?

Wouldn't it be shit code if the widget is self-sufficient? Those. if the widget is called, it independently climbs into the database for the data it needs, then builds some kind of html based on them and shows the result. Or is it still more correct to collect data through the model\controller and then transfer it to this widget (which will form the current display and connect the necessary assets)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita, 2016-08-08
@AlikDex

"Developed widgets should be self-contained. This means that to use them, it should be enough just to add the widget to the view"
A piece from the documentation.
Why not look at the documentation first?
Read the documentation even for TV remotes! Stop pointing your finger at the sky.

M
Maxim Timofeev, 2016-08-09
@webinar

The widget should not go into the base, it should receive data from the view
. If a base is needed, etc. Then it should already be a module. And a widget as part of this module. Accordingly, there must be migrations that will create the desired architecture in the database. And there must be CRUD to manage this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question