zoukankan      html  css  js  c++  java
  • Laravel Formbuilder使用

    添加formbuilder插件:

    Composer应用

     

    composer require kris/laravel-form-builder

     

    下载成功

    修改配置文件

    config/app.php

     

    providers => [

      Kris\LaravelFormBuilder\FormBuilderServiceProvider::class,

    ]

    ‘aliases’ =>[

      'FormBuilder' =>  Kris\LaravelFormBuilder\Facades\Formbuilder::class,

    ]

     

    创建form

     

    Php artisan make:form Forms/名字–fields =name:text,intro:text”

     

    生成的文件

    public function buildForm()
    
    {
    
        $this
    
            ->add('name', 'text', [             'rules' => 'required|min:5'         ])         ->add('lyrics', 'textarea', [             'rules' => 'max:5000'         ]); }

     

    创建一个空的form

    Php artisan make:form Forms/名字

     

    public function buildForm()
    
    {
    
        }

     

    控制器

    引用:

    use Kris\LaravelFormBuilder\FormBuilder;

     

    函数:

    public function create(FormBuilder $formBuilder){
    
        $form = $formBuilder->create(\App\Form\PostForm::class,[        'method' => 'POST',         'url' => route('photo.store')     ]);     return view('Photo.form',compact('form')); }

    视图:

    <!DOCTYPE html>
    
    <html lang="en"> <head>   <meta charset="UTF-8">   <title></title> </head> <body>   {!! form($form) !!} </body> </html>
  • 相关阅读:
    iframe跨域
    changePage() 页面跳转
    APACHE启动失败是SYSTEM对apache目录没权限导致
    git使用中出现的错误
    python面试总结
    python面试30-40题
    python面试1-30题
    购物车的基本流程
    vue的基础知识
    三大框架的对比
  • 原文地址:https://www.cnblogs.com/lxwphp/p/15454344.html
Copyright © 2011-2022 走看看