Answer the question
In order to leave comments, you need to log in
How do you pass data to templates?
Actually a question. Just separate pieces, or collect 1 array for example. and transmit?
Well, for example, we create a profile editing page, collect the necessary models in the controller, and add them to the template:
return $this->render('profile', [
'user' => $user,
'profile' => $profile,
'passwordForm' => $passwordForm,
'avatar' => $avatar,
]);
$data = [
'user' => $user,
'profile' => $profile,
'passwordForm' => $passwordForm,
'avatar' => $avatar,
];
return $this->render('profile', [
'data' => $data,
]);
Answer the question
In order to leave comments, you need to log in
Is there a difference? The choice of this or that method should be justified by something. Which is faster, which is easier to read? Which is more convenient. In my opinion, there is no point in an array, it is less flexible and requires extra code, then why? But in your architecture it can be justified.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question