Laravel表单显示数据

时间:2016-05-26 20:02:34

标签: php laravel-5 laravel-5.1 laravel-5.2

我在homeController中创建了一个用户数组,然后在home.blade.php文件中呈现它的数据。但是当我尝试提交表单时,我收到一条错误消息:未定义的变量:usersArray

这是我的 home.blade.php:

{!! Form::open(array('id' => 'activateForm')) !!}

{!! csrf_field() !!}

<div>

<div class="home-rounded-border  center-content">
        <input type = "checkbox" id = "checkAll" />Select All<span style="padding-left: 310px;font-weight: bold;">Email</span><br/>
        @foreach($usersArray as $key => $value)
        <ul>
            <li>
                <input type="checkbox" id="checkboxUser{{$key}}" name="user-name-checkbox{{$key}} ">{{$value}}
                <input type = "email" class="styled-text  rounded" name = "name" id = "customer-name-inputField{{$key}}" placeholder=""/><br/><br/>
            </li>
        </ul>
        @endforeach

    <center><input type = "submit" class="sign-in-button"value = "Submit"/></center>

    </br>
    <div id="statusMsg" style="margin: 0px 40px 0px 40px; background-color: #ffffff;"></div>

    <ul><li class="logout"><a href="logout"><span>Logout</span></a></li></ul>

</div>

<br/><br/>
 </div>
 {!! Form::close() !!}

2 个答案:

答案 0 :(得分:0)

也许是您的<input type = "email" class="styled-text rounded" name = "name" id = "customer-name-inputField{{$key}}}}" placeholder=""/><br/><br/>,您在$ key

之后添加了4x }

答案 1 :(得分:0)

您还需要在post函数中定义usersArray。哪个处理帖子请求。