Ich habe eine Tabelle mit Kontrollkästchen als Array und Textbox als auch Array. Was ich erreichen möchte, ist, wenn der Benutzer eine Checkbox aktiviert hat, sollte er validieren, dass die Eingabetextbox nicht leer ist.Validierung mit required_with in Laravel für Input-Feld als Array?
public function roombooking(Request $request) { $messsages = array( 'check.required'=>'No room was selected.Please select room to proceed for booking !', 'txtnos.required|numeric'=>'Please enter no of persons', ); $rules = array( 'check'=>'required', 'txtnos'=>'required_with:data', //txtnos is a array input filed and data is a array checkbox ); $validator = Validator::make($request->all(), $rules,$messsages ); if ($validator->fails()) { return Redirect::back() ->withErrors($validator) ->withinput(); } }
Html-Code
<table class="table table-hover" data-toggle="table" id="table" data-click-to-select="true"> <thead> <tr> <th style="width:10%;" data-field="ActivityId">Select</th> <th style="width:30%;" data-field="ActivityName">Activity Name</th> <th style="width:30%;" data-field="Rate">Rate/Person</th> <th style="width:30%;">Nos. of person</th> </tr> </thead> <tbody> @foreach($loadactivity as $key=>$activity) <tr> <td> <input type="checkbox" name="data[]" value="0;{!! $activity->ActivityId !!};{!! $activity->Rate !!};0;0;{!! $activity->ActivityName !!}" /> </td> <td>{!! $activity->ActivityName !!}</td> <td>{!! $activity->Rate !!}</td> <td >{!! Form::text('txtnos[]','',['class' => 'form-control small-textbox ','txtnoid'=>$activity->ActivityId]) !!}</td> </tr> @endforeach </tbody> </table>
bitte helfen Sie mir
Bitte geben Sie den HTML-Code für das Formular – SebHallin