猿问

在刀片表单组件中包含 Auth

我有以下代码:


<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">

    @include('component.input',[

        'label' => 'Last Name',

        'name' => 'last_name',

        'type' => 'text',

        'placeholder' => 'Li',

        'class' => '',

        'errorMessage' => "required"

    ])

</div>

我想做类似的事情:


<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">

    @include('component.input',[

        'label' => 'Last Name',

        'name' => 'last_name',

        'type' => 'text',

        'placeholder' => "{{Auth::user()->last_name}}"

        'class' => '',

        'errorMessage' => "required"

    ])

</div>

但它返回的语法错误。


慕姐4208626
浏览 126回答 1
1回答

牛魔王的故事

在@include标签内时,您处于 PHP 的上下文中,因此您可以直接使用外观:<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">&nbsp; &nbsp; @include('component.input',[&nbsp; &nbsp; &nbsp; &nbsp; 'label' => 'Last Name',&nbsp; &nbsp; &nbsp; &nbsp; 'name' => 'last_name',&nbsp; &nbsp; &nbsp; &nbsp; 'type' => 'text',&nbsp; &nbsp; &nbsp; &nbsp; 'placeholder' => Auth::user()->last_name,&nbsp; &nbsp; &nbsp; &nbsp; 'class' => '',&nbsp; &nbsp; &nbsp; &nbsp; 'errorMessage' => "required"&nbsp; &nbsp; ])</div>
随时随地看视频慕课网APP
我要回答