My solution for my setting, my setting's key only one.
View
{!! Form::open() !!}
{!! Form::text('example') !!}
{!! Form::text('example-2') !!}
{!! Form::submit('Submit') !!}
{!! Form::close()!!}
Controller
public function postSetting(){
$data = Request::all();
$validator = Validator::make($data,[Your validator array]);
if($validator->fails()){
return redirect()->back()->withInput->withErrors();
}
else {
foreach($data as $input){
// Make your update
}
}
}
can I see the controller code that handles this?
journeyman73 said:
I have a form that I want to be able to update multiple rows at once. I have found online the method for the controller but I just can get the form to return an array for each row. I get an error Cannot use [] for reading
Any ideas??
{!! Form::model($settings, ['method' => 'PATCH', 'action' => ['SettingsController@update', $settings[]]]) !!} @foreach ($settings as $setting) <tr> <td>{{$setting->setting_name}}</td> <td> @if ($setting->setting_type == 'text') {!! Form::text( $setting[$setting->id][$setting->slug] , $setting->setting_value, array('class'=>$setting->slug) ) !!} @elseif ($setting->setting_type == 'textarea') {!! Form::textarea( $setting[$setting->id][$setting->slug], $setting->setting_value, array('class'=>$setting->slug, 'rows'=>'8' )) !!} @else {!! Form::text( $setting[$setting->id][$setting->slug] , $setting->setting_value, array('class'=>$setting->slug) ) !!} @endif </td> <td> <a href="#" data-reveal-id="{{ $setting->slug }}"><i class="fa fa-question-circle"></i></a> <div id="{{ $setting->slug }}" class="reveal-modal tiny" data-reveal aria-labelledby="{{$setting->setting_name}}" aria-hidden="true" role="dialog"> <h2 id="modalTitle">{{$setting->setting_name}}</h2> <p class="lead">{{$setting->setting_description}}</p> <p><strong>Reference:</strong> {{ $setting->slug }}</p> <a class="close-reveal-modal" aria-label="Close">×</a> </div> </td> </tr> @endforeach <tr> <td> {!! Form::submit($submit_text, array('class' => 'button tiny')) !!} </td> </tr> {!! Form::close() !!}
Cheers
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community