Ok so I have added in the Form functionality just fine in Laravel 5 and have been using it through out these tutorials. I am brand new to Laravel in general and can't see to find out what is going wrong. I have a nested route that is todos.items.create, so to create a new item in that list I would have to pass that ID into the Form::open tag. However when doing so I get a Whoops, looks like something went wrong. Now if I remove the $todo_list->id parameter the page loads fine but with it I always get this error. Here is my code
Controller:
public function create($list_id)
{
$todo_list = TodoList::findOrFail($list_id);
return view('items.create', ['TodoList' => $todo_list]);
}
Create View (create.blade.php in side my items folder inside the views folder)
{!! Form::open(array('route' => ['todos.items.store', $todo_list] )) !!}
When just doing the below it renders fine but doing the above which is needed it doesn't. This is because I need the id of the list in which to create the new item in.
{!! Form::open(array('route' => ['todos.items.store'] )) !!}
Routes:
Route::get('/', 'TodoListController@index');
Route::resource('todos', 'TodoListController');
Route::resource('todos.items', 'TodoItemController', ['except' => ['index', 'show'] ]);
Any ideas what I am doing wrong here? I have ran a var_dump of $todo_list->id before the return of the view just to check things and it returned the proper id.
You've created the $todo_list object but have passed it to your view as $TodoList.
Try using the following instead
return view('items.create', ['todo_list' => $todo_list]);
When calling the view from the controller, the key used in your array of data is what the variable will be available as on the pages.