2014-11-10 2 views
1

나는 희소 한 문제점이있다, 나는 PHP로 laravel 4를 사용하고 있고 jquery 데이터 테이블에 "Delete"버튼이있다. 그리고 나는 y를 삭제할 것이다. tipos.destoy 메서드를 호출하고 잘 작동하는 버튼을 prees합니다! 하지만 첫 번째 삭제 버튼을 누르면 예외가 발생합니다 : Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException.Symfony Component HttpKernel Exception MethodNotAllowedHttpException, delete button

경로 :

Route::resource('tipos', 'TiposController'); 

컨트롤러 :

public function destroy($id) 
    { 
     $this->tipo->find($id)->delete(); 
     return Redirect::route('tipos.index'); 
    } 

모델 :

protected $guarded = array(); 

protected $table = 'tipos'; 

protected $fillable = array('clave_tipo', 'nombre_tipo', 'created_by', 'updated_by'); 

public static $rules = array(
    'clave_tipo' => 'required', 
    'nombre_tipo' => 'required', 
    'created_by' => 'required', 
    'updated_by' => 'required' 
); 

보기 :

@foreach($tipos as $tipo) 
    <tr> 
     <td>{{{ $tipo->clave_tipo }}}</td> 
     <td>{{{ $tipo->nombre_tipo }}}</td> 
     <td>{{ link_to_route('tipos.edit', 'EDITAR', array($tipo->id), array('class' => 'btn btn-success')) }}</td> 
     <td> 
      {{ Form::open(array('method' => 'DELETE', 'route' => array('tipos.destroy', $tipo->id))) }} 
      {{ Form::submit('Delete', array('class' => 'btn btn-danger')) }} 
      {{ Form::close() }} 
     </td> 
    </tr> 
@endforeach 

왜 다른 모든 버튼에도 잘 작동하는지 잘 모르겠지만 첫 번째 버튼이 예외를 throw합니다. 도움이 될 것입니다. 내가 laravel 또는 무언가의 버그가 생각

<td> 
    <form method="POST" action="http://localhost/posm/public/tipos/" accept-charset="UTF-8"><input name="_method" type="hidden" value="DELETE"><input name="_token" type="hidden" value="zrWDtdGVRnzreYGnZizSHqeIo7jPQlXBlGP03iJW"> 
    </form> 
    {{ Form::open(array('method' => 'DELETE', 'route' => array('tipos.destroy', $tipo->id))) }} 
    {{ Form::submit('Delete', array('class' => 'btn btn-danger')) }} 
    {{ Form::close() }} 
</td> 

나는 분명히 내가이 일을 왜 모르겠지만, 덕분에 작동합니다

나는이 문제를 해결
+0

Form :: open()에서 경로를 지정할 때 http 메서드를 설정하지 않아야합니다. – ArjanSchouten

+0

죄송합니다. 이해가되지 않습니다. 더 구체적으로 부탁해주십시오. –

+0

당신이 묻는 것을 명확하게하기 위해서, 당신의 특정 문제는 위의 폼에서'btn-danger' 엘리먼트를 클릭했을 때 Laravel이'MethodNotAllowed' 예외를 던지고있는 것이 아닌가? –

답변

0

, 난 그냥 다른 형태를 추가 !

관련 문제