我试图用一个对应的控制器方法创建一个表单,该方法向DB添加一个新的记录. Laravel版本是4.1
原文链接:https://www.f2er.com/php/138209.html应用/视图/ projects.blade.PHP
<tr> {{Form::open(array('action' => 'ProjectController@createProject','method' => 'post'))}} <td>{{Form::text('project_number')}}</td> <td>{{Form::text('title')}}</td> <td>{{Form::text('client')}}</td> <td>{{Form::text('comment')}}</td> <td> {{Form::file('xmlfile')}}<br /> {{Form::submit('Hinzufügen',array('class' => 'blue'))}} </td> {{ Form::close() }} </tr>
应用程序/控制器/ ProjectController
<?PHP class ProjectController extends BaseController { public function listProjects(){ $projects = Project::all(); return View::make('projects',array('projects' => $projects)); } public function createProject(){ /* handling the form data later . . . */ return "Hello"; } } ?>
// Project Routes Route::get('/projects',array('as' => 'listProjects','uses' => 'ProjectController@listProjects')); Route::get('/projects/{id}',array('as' => 'actionProject','uses' => 'ProjectController@actionProject')); // Canal Routes Route::get('/canals',array('as' => 'listCanals','uses' => 'CanalController@listCanals'));
错误信息
ErrorException Route [ProjectController@createProject] not defined.
(View: /var/www/virtual/hwoern/laravel/app/views/projects.blade.PHP)