我有以下代码返回带有子视图的视图。正如它所看到的,子视图重复了变量 $form 和数组 &fields 将变量的传递复制到视图中。
如何从 responseView 继承 userProfileInformationView 这些变量并将它们仅注入 responseView?
$responseView = new ViewModel();
$responseView->setVariables(array(
'form' => $form,
'fields' => $fields,
'userType' => $userType,
));
$responseView->setTemplate('templates/logged_user_profile');
$responseView->setTerminal(true);
$userProfileInformationView = new ViewModel();
$userProfileInformationView->setTemplate('templates/logged_user_profile_information');
$userProfileInformationView->setVariables(array(
'form' => $form, //I don't want this
'fields' => $fields, //I don't want this
));
$responseView->addChild($userProfileInformationView, 'userProfileInformation');
return $responseView;