0
votes

I just have a very simple product category creation form in laravel , like so:

{{ Form::open(array('url'=>'admin/category/create')) }}
          <p>
            {{ Form::label('name') }}
            {{ Form::text('name') }}
          </p>
          {{ Form::submit('Create Category' , array('class'=>'secondary-cart-btn')) }}
          {{ Form::close() }}

For the create method i have the following code:

  public function postCreate() {

    $validator = Validator::make(Input::all() , Category::$rules);

    if($validator->passes()) {
      $category = new Category;
      $category->name = Input::get('name');
      $category->save();

      return Redirect::to('admin/categories/index')
         ->with('message' , 'Category created');
    }

    return Redirect::to('admin/categories/index')
      ->with('message' , 'something went wrong')
      ->withError($validator)
      ->withInput();

  }

Now when i click on the submit button, i get the following error:

C:\xampp\htdocs\ecomm\bootstrap\compiled.php

if (!is_null($route)) { return $route->bind($request); } $others = $this->checkForAlternateVerbs($request); if (count($others) > 0) { return $this->getOtherMethodsRoute($request, $others); } throw new NotFoundHttpException(); } protected function checkForAlternateVerbs($request)

You can see the error more visvually HERE.

What am i doing wrong ?

1
Laravel can't find the routes when you redirect the form.aldrin27
can you give me the code of routes where you are sending the data?aldrin27
show your routes.php?Imtiaz Pabel
my routes.php file looks like so chopapp.com/#vgz54ia4 .(wait 5 secs for the code to load)Alexander Solonik
Can you insert the return 'true'; after $validator->passes(); If it's returning the word TRUE?aldrin27

1 Answers

3
votes

Instead of

{{ Form::open(array('url'=>'admin/category/create')) }}
      <p>
        {{ Form::label('name') }}
        {{ Form::text('name') }}
      </p>
      {{ Form::submit('Create Category' , array('class'=>'secondary-cart-btn')) }}
      {{ Form::close() }}

try this:

{{ Form::open(array('route'=>'post.homes')) }}
      <p>
        {{ Form::label('name') }}
        {{ Form::text('name') }}
      </p>
      {{ Form::submit('Create Category' , array('class'=>'secondary-cart-btn')) }}
      {{ Form::close() }}

In routes.php:

Route::post('aboutus', array('as' => 'post.homes', 'uses' => 'HomeController@postContactUs'));