I am trying to edit a row in my database. I try to load the edit form with the content in it as below but i seem to get an error: "Some mandatory parameters are missing ("matches") to generate a URL for route "matches.update". "
@extends('master')
@section('content')
<h1>Compare Ages</h1>
{{ Form::open(array('action' => 'MatchesController@update')) }}
{{ Form::label('n1label', 'Person 1: ') }}
{{ Form::text('name1', $match->name1) }}<br/>
{{ Form::label('v1label', 'Age: ') }}
{{ Form::text('val1', $match->val1) }}<br/><br/>
{{ Form::label('n2label', 'Person 2: ') }}
{{ Form::text('name2', $match->name2) }}<br/>
{{ Form::label('v2label', 'Age: ') }}
{{ Form::text('val2', $match->val2) }}<br/><br/>
{{ Form::submit('Update Pair') }}
{{ Form::close() }}
@stop
This is what I have on my controller for the edit and the update method:
public function edit($id)
{
print_r(Mydata::find($id));
return View::make('matches.edit')
->with('title', 'Edit Match')
->with('match', Mydata::find($id));
}
public function update($id)
{
$input = Mydata::where('id', Mydata::find($id));
$new_input = array(
'name1'=>Input::get('name1'),
'val1'=>Input::get('val1'),
'name2'=>Input::get('name2'),
'val2'=>Input::get('val2')
);
$input->update($new_input);
return Redirect::to('matches')
->with('message', 'Match updated successfully!');
}
Please let me know how i can load the content on matches/edit form and save after editing using route matches/update then get redirected to matches/$id with the updated data