Currently i'm working on a project to manage my cost on fuel.
Now i try to pass 2 parameters in a Form::open()
which sadly doesn't work.
The reason why i think i need to pass 2 parameters at once is because my url is Sitename/car/{id}/tank/{id}
What am i doing wrong?
edit.blade.php
Form::open(array('class' => 'form-horizontal', 'method' => 'put', 'action' => array('TankController@update', array($aid, $id))))
Problem Code
'action' => array('TankController@update', array($aid, $id)
-Results in the following error:
Parameter "tank" for route "car.{id}.tank.update" must match "[^/]++" ("" given) to generate a corresponding URL.
TankController.php
public function edit($id, $tid)
{
$tank = Tank::find($tid);
if(!$tank) return Redirect::action('TankController@index');
return View::make('Tank.edit', $tank)->with('aid', $id);
}
public function update($id, $tid)
{
$validation = Validator::make(Input::all(), Tank::$rules);
if($validation->passes()){
$tank = Tank::find($tid);
$tank->kmstand = Input::get('kmstand');
$tank->volume = Input::get('volume');
$tank->prijstankbeurt = Input::get('prijstankbeurt');
$tank->datumtank = Input::get('datumtank');
$tank->save();
return Redirect::action('TankController@index', $id)->with('success', 'Tankbeurt succesvol aangepast');
} else return Redirect::action('TankController@edit', $id)->withErrors($validation);
}
Route.php
Route::resource('car', 'CarController');
Route::resource('car/{id}/tank', 'TankController');
Route::controller('/', 'UserController');
-Url Structure SITENAME/car/2/tank/2/edit
I've also looked into the api documents but found nothing. http://laravel.com/api/source-class-Illuminate.Html.FormBuilder.html
Thanks in advance
Try this:
Form::open(array('class' => 'form-horizontal', 'method' => 'put', 'action' => array('TankController@update', $aid, $id)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With