0

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() !!} <div> <!---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> @endforeach </ul> </div> @endif </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() !!} 

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

Do I need to declare $userArray in activateCustomer? if yes how would the implementation be? Thanks!
if you want to show home view if the submission was sucessfull, you can call back to home() method using return redirect()->to('home')

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.