laravel表格发布 [英] laravel form post issue

查看:72
本文介绍了laravel表格发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel框架构建实践应用程序,我在其中一个视图中构建了一个表单,该视图设置为 post 到同一视图本身,但是当我单击提交"时,该表单即被发布但是我没有得到想要的输出,我再次看到了原始视图.

I am building a practice app with the Laravel framework I built a form in one of the views which is set to post to the same view itself but when I hit submit the form is posted however I do not get the desired output, I see the original view again.

这是我的观点 index.blade.php

@extends('master')

@section('container')

<div class="wrapper">

    {{ Form::open(array('url' => '/', 'method' => 'post')) }}
        {{ Form::text('url') }}
        {{ Form::text('valid') }}
        {{ Form::submit('shorten') }}
    {{ Form::close() }}

</div><!-- /wrapper -->

@stop 

和我的 routes.php

Route::get('/', function()
{
return View::make('index'); 
});

Route::post('/', function() 
{
return 'successfull';
});

到目前为止我已经尝试过的

What I've tried so far

  • 我尝试将帖子更改为其他视图,并且可以正常工作. 但是我希望表单将其发布到同一视图本身.

  • I tried changing the post to a different view and it worked. However I want the form to post to the same view itself.

我没有返回一个字符串,而是试图返回一个视图 没用.

Instead of returning a string I tried to return make a view still it didn't work.

我在做什么错了?

我看到当表单发出发布请求时,我得到了301 MOVED PERMANENTLY HEADER

I see that when the form is making the post request I am getting a 301 MOVED PERMANENTLY HEADER

推荐答案

{{ Form::open(array('url' => ' ', 'method' => 'post')) }}

传递一个空格作为url对我有用.

Passing a space as the url has worked for me.

这篇关于laravel表格发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆