dtdsbakn210537 2014-08-11 23:39
浏览 27

Laravel 4 - 形成行动路线问题

I have a problem with a form, and its route..

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException

I have this:

{{ Form::model(array('route' => 'rrhh.cursos.store', 'method' => 'POST'), array('role' => 'form', 'id' => 'formulario')) }}

This is the route or action of the form.

Route::get('rrhh/empleados/{id}/cursos',array('uses'=>'CursosController@show', 'as' => 'rrhh.cursos.show'));

Route::post('rrhh/empleados/{id}/cursos/store',array('uses'=>'CursosController@store', 'as' => 'rrhh.cursos.store'));

I have these routes:

public function store($id)
{
    // Creamos un nuevo objeto para nuestro nuevo usuario
    $curso = new Curso;
    // Obtenemos la data enviada por el usuario
    $data = Input::all();

    // Revisamos si la data es válido
    if ($curso->isValid($data,false))
    {
        // Si la data es valida se la asignamos al usuario
        $curso->fill($data);
        // Guardamos el usuario
        $curso->save();
        // Y Devolvemos una redirección a la acción show para mostrar el usuario
        return Redirect::route('rrhh.cursos.show', array($data->cedula));
    }
    else
    {
    // En caso de error regresa a la acción create con los datos y los errores encontrados
    return Redirect::route('rrhh.cursos.show', array($data->cedula))->withInput()->withErrors($empleado->errors)->with('error_flag',true);
    }
 }


/**
 * Display the specified resource.
 *
 * @param  int  $id
 * @return Response
 */
public function show($id)
{
   $empleado = Empleado::find($id);
   $cursos = $empleado->cursos;
   return View::make('rrhh/cursos/index_cursos')->with('cursos',$cursos)->with('id',$id);
 }

When I press the register button, it makes the action of the form and it gives the error and when I inspect the code from Google Chrome, the action of the form gives another URL

form method="POST" action="http://localhost:8080/demosigal/public/rrhh/empleados/1/cursos" accept-charset="UTF-8" role="form" id="formulario"><input name="_token" type="hidden" value="2YSLitvrYvRSB6gYFHp7MAD4CXYKqwW2hg3aZZl6">

This must send me to rrhh.cursos.store but it sends me to the same page where the form is. How do I resolve this problem?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向