0
私はこの単純なフォームに取り組んでおり、それを提出しようとしています。基本的には私のHomeController.phpにユーザーの配列を作成し、そのデータをhome.blade.phpファイルにレンダリングします(その部分はうまくいきます)。しかし、私がフォームを提出しようとすると、次のようなエラーが出る:未定義の変数:usersArray。私が間違っていることを教えてもらえますか?あまり前もってありがとうございます。Laravelでフォームを送信するには?
はここで、それはあなたのactivateCustomer
上return view('home', ['userId' => $adminId]);
だ私の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() !!}
activateCustomerで$ userArrayを宣言する必要はありますか?はいの場合、実装はどのようになりますか?ありがとう! – progx
投稿がsucessfullだった場合にホームビューを表示したい場合は、 'return redirect() - > to( 'home')' –
を使って 'home()'メソッドを呼び出すことができます。出来た!! – progx