Support the ongoing development of Laravel.io →
Database Forms
Last updated 2 years ago.
0

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
		}
	}
}
Last updated 9 years ago.
0

I can do that, but I want to do multiple rows at once cheers

0

bump to to get above spam

0

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

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.