There are 2 tables - customers and orders. One connection to many. How in one view to bring information about the client from the model "clients", and below the list of all his orders using the model "orders"? I read that something like this is realized through the widget, is it correct? And how to implement it?
1 answer
In your controller you get a client model:
$client = ClientActiveRecord::findById($_GET['client_id']); Pass this $ client to the view.
And in the view after the output of customer information write like this:
foreach($client->getOrders() as $order) { // вызываете под вьюшку для заказа либо var_dump($order); } Or call the samopisny widget:
OrdersWidget::run($client->getOrders()); There are lots of options.
|