【问题标题】:laravel form is not working even after every particular step即使在每个特定步骤之后,laravel 形式也无法正常工作
【发布时间】:2018-01-19 19:01:06
【问题描述】:

在 composer.json 中 要求 { “laravelcollective/html”:“^5.5” }

{!! Form::open(['route' => 'blogs.store']) !!}
  <div class="col-md-6">
    <div class="form-group">
     {!! Form::label('title', 'Blog Title') !!}
     {!! Form::text('title', null,['class'=>'form-control']) !!}
    </div>
    <div class="form-group">
     {!! Form::label('body', 'Blog Body') !!}
     {!! Form::textarea('body', null,['class'=>'form-control']) !!}
    </div>
    <div class="form-group">
     {!! Form::submit('Add Blog', ['class'=>'btn btn-primary']) !!}
    </div>
  </div>

{!! Form::close() !!}

在控制器中

public function store(BlogRequest $request)
{
   $input = Request::all();
   Blog::create($input);
   return redirect(blogs);         
}

应用程序中的提供者

Collective\Html\HtmlServiceProvider::class,

应用中的别名

'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,

提交后表单无法正常工作 在地址栏中显示值这是它显示的内容

http://localhost/lynda/blogs/create?_token=dIQXrWadbNNJhCBMUYjUAAOM1MPXDmhD782rlJ0F&title=aaaaa&body=aaaa

【问题讨论】:

  • 请清除缓存并运行以下命令:1) php artisan config:cache 2) php artisan cache:clear
  • 请给我错误
  • 你在更新 composer.json 后运行composer update 了吗?如果已经尝试composer dump-autoload 然后composer update
  • form not working 不是任何人都可以帮助您的错误消息。什么不工作?发生了什么,您预计会发生什么?

标签: laravel


【解决方案1】:

请在您的表单中添加一个方法。如果你没有方法,它会使用get方法。

{!! Form::open(['method' => 'post', 'route' => 'blogs.store']) !!}

【讨论】:

  • localhost/lynda/blogs/… 它仍然无法在地址栏中显示的内容
  • 你是不是用post方法设置了你的路线,别忘了在表单中添加post方法。
【解决方案2】:

你应该试试这个:

1) 在终端/cmd 中运行 composer dump-autoload 后,首先运行 composer update 以更新您的 html

2) 请清除缓存并在终端/cmd中运行此命令

php artisan config:cache 

php artisan cache:clear

3)

        public function store(BlogRequest $request)
        {
            $input = $request->all();
            Blog::create($input);
          return redirect('blogs');

        }

【讨论】:

  • @MohammadMaroofMalik:请 dd($input);exit;并检查给定的值
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-09-27
  • 1970-01-01
  • 2016-05-01
  • 2016-02-01
  • 2020-04-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多