Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [laravel] problem z routingiem
dżozef
post 22.07.2013, 21:12:15
Post #1





Grupa: Zarejestrowani
Postów: 125
Pomógł: 9
Dołączył: 25.05.2013

Ostrzeżenie: (0%)
-----


routes.php:
  1. <?php
  2. Route::controller('/', 'SnippetsController');

snippetsController:
  1. <?php
  2.  
  3. class SnippetsController extends BaseController {
  4.  
  5. public function getIndex(){
  6. return View::make('snippet.new');
  7. }
  8.  
  9. public function postIndex() {
  10. return 'post';
  11. }
  12. }

snippet/new.blade.php:
  1. @extends('master')
  2.  
  3. @section('container')
  4. {{ Form::open(array('url'=>'/', 'method'=>'post')) }}
  5. {{ Form::textarea('snippet') }}
  6. {{ Form::submit('Save') }}
  7. {{ Form::close() }}
  8. @stop


teoretycznie naciśnięcie [Save] powinno odpalić metodę postIndex(), jednak z jakichś powodów cały czas pokazuje mi getIndex()
co robię źle?

podbijam


--------------------
Go to the top of the page
+Quote Post
Dejmien_85
post 23.07.2013, 12:32:09
Post #2





Grupa: Zarejestrowani
Postów: 251
Pomógł: 23
Dołączył: 23.04.2013

Ostrzeżenie: (0%)
-----


  1. Form::open(array('action' => 'Controller@method'))


Ten post edytował Dejmien_85 23.07.2013, 12:45:36
Go to the top of the page
+Quote Post
dżozef
post 23.07.2013, 15:29:40
Post #3





Grupa: Zarejestrowani
Postów: 125
Pomógł: 9
Dołączył: 25.05.2013

Ostrzeżenie: (0%)
-----


  1. InvalidArgumentException
  2. Unknown action [SnippetsController@Index]


--------------------
Go to the top of the page
+Quote Post
pitu
post 23.07.2013, 16:12:13
Post #4





Grupa: Zarejestrowani
Postów: 476
Pomógł: 96
Dołączył: 10.04.2008
Skąd: Koszalin

Ostrzeżenie: (0%)
-----


Masz wskazać na konkretną metodę, czyli w Twoim przypadku:
  1. Form::open(array('action' => 'SnippetsController@postIndex'))


--------------------
HTML/CSS/JS: jsfiddle
SQL: sqlfiddle
Go to the top of the page
+Quote Post
dżozef
post 23.07.2013, 17:44:32
Post #5





Grupa: Zarejestrowani
Postów: 125
Pomógł: 9
Dołączył: 25.05.2013

Ostrzeżenie: (0%)
-----


aż tak zielony nie jestem. próbowałem na dziesiątki różnych sposobów, z post/put ale ciągle nie działa, na końcu spróbowałem bez - i też lipa


--------------------
Go to the top of the page
+Quote Post
Dejmien_85
post 24.07.2013, 14:29:06
Post #6





Grupa: Zarejestrowani
Postów: 251
Pomógł: 23
Dołączył: 23.04.2013

Ostrzeżenie: (0%)
-----


Cytat(dżozef @ 23.07.2013, 18:44:32 ) *
aż tak zielony nie jestem. próbowałem na dziesiątki różnych sposobów, z post/put ale ciągle nie działa, na końcu spróbowałem bez - i też lipa


Czyli metoda i kontroler nie są zarejestrowane przez Laravela, dodaj do routes.php (albo nawet i w widoku formularza):

  1. Route::post('route', 'Controller@method');

Go to the top of the page
+Quote Post
dżozef
post 24.07.2013, 14:46:16
Post #7





Grupa: Zarejestrowani
Postów: 125
Pomógł: 9
Dołączył: 25.05.2013

Ostrzeżenie: (0%)
-----


przecież zarejestrowałem kontroler (patrz pierwszy post), jaki jest więc sens dublowania tego kolejnym ::post ?
dodam, że z innym route działa bez problemu, ale z / nie chce ni cholery

Ten post edytował dżozef 24.07.2013, 14:46:55


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 5.07.2025 - 09:43