php - Routing back to index ( / ) -
i have come across problem can't seem figure out.
i doing project in laravel 4, , have form handle navigation between different pages. routes between pages got there, except when try click on 1 return in index file.
attempting promts me notfoundhttpexception.
the navigation:
<td><form action="/" method="post"><input type="submit" name="ht" value="hver time" /></form></td> <td><form action="hverdag" method="post"><input type="submit" name="hd" value="hver dag" /></form></td> <td><form action="hvertirsdag" method="post"><input type="submit" name="htirs" value="hver tirsdag" /></form></td> <td><form action="kontrollcm" method="post"><input type="submit" name="kcm" value="kontroll cm" /></form></td> <td><form action="hvertredjetime" method="post"><input type="submit" name="htt" value="hver tredje time" /></form></td>
routes.php:
route::get('/', 'homecontroller@showindex'); //routen å vise index.php route::post('/hverdag', 'homecontroller@showhd'); route::post('/hvertredjetime', 'homecontroller@showhtt'); route::post('/hvertirsdag', 'homecontroller@showhtirs'); route::post('/kontrollcm', 'homecontroller@showkontrollcm');
aaaand homecontroller.php:
public function showindex() { return view::make('index'); } public function showhd() { return view::make('hverdag'); } public function showhtirs() { return view::make('hvertirsdag'); } public function showkontrollcm() { return view::make('kontrollcm'); } public function showhtt() { return view::make('hvertredjetime'); }
also on exception error page, url same url working index page, before trying route (i can click url , press enter make work). can't fathom why exception there, thank time guys/gals!
first change
route::get('/','homecontroller@showindex');
to
route::any('/','homecontroller@showindex');
or
route::get('/','homecontroller@showindex'); route::post('/','homecontroller@showindex');
because using form method post, route should accept post, , make sure paths correct: add the
asset();
function
<td><form action="{{asset('/')}}" method="post"><input type="submit" name="ht" value="hver time" /></form></td> <td><form action="{{asset('hverdag')}}" method="post"><input type="submit" name="hd" value="hver dag" /></form></td>
Comments
Post a Comment