尝试将多个变量分配给刀片模板

时间:2014-05-12 18:43:07

标签: php laravel laravel-4 blade

我尝试将多个变量分配给刀片模板,但它返回异常

未定义变量:transactions(查看:/home/u305199682/public_html/dash/protected/app/views/pages/template/home.blade.php)

$this->layout->nest('content',$page)
    ->with(array(
        'menus' => $this->menus,
        'transactions' => $transaction
    )
);

2 个答案:

答案 0 :(得分:1)

如果您想将数据传递到嵌套视图,请尝试

$this->layout->nest('content', $page, array(
    'menus' => $this->menus,
    'transactions' => $transaction
));

答案 1 :(得分:0)

您需要为每个变量调用

$this
    ->layout
    ->nest('content',$page)
    ->with('menus',$this->menus)
    ->with("transactions",$transaction);

或将两个变量放入1个数组中。

$passVar = array(
                 'menus' => $this->menus,
                 'transaction' => $transaction
                );

$this
    ->layout
    ->nest('content',$page, $passVar);