progx progx - 4 months ago 6x
PHP Question

How to submit a Form in Laravel?

I'm working on this simple form and trying to submit it. Basically I created an array of users in my HomeController.php which then renders its data in the home.blade.php file (That part works fine). However when I try to submit the form I get an error that says: Undefined variable: usersArray .Can anyone tell me what I'm doing wrong please? thank you so much in advance.

Here's my Home.blade.php

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

{!! csrf_field() !!}


<!---Error messages inside of box-->
<div style="padding-left: 135px; width:815px;">

@if (count($errors) > 0)
<div class="alert alert-danger">
<ul class = "login-error-messages" style = "list-style-type:disc;">
@foreach ($errors->all() as $error)
<li>{!! $error !!}</li>

<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)
<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/>

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

<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>


{!! Form::close() !!}


it's return view('home', ['userId' => $adminId]); on your activateCustomer. you are trying to render home view without $usersArray