当前位置:网站首页>Laravel form builder uses

Laravel form builder uses

2022-07-07 13:52:00 Full stack programmer webmaster

add to formbuilder plug-in unit :

Composer application

composer require kris/laravel-form-builder

Download successful

Modify the configuration file

stay config/app.php

‘providers’ => [

  Kris\LaravelFormBuilder\FormBuilderServiceProvider::class,

]

‘aliases’ =>[

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

]

establish form

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

Generated files

public function buildForm()

{

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

Create an empty form

Php artisan make:form Forms/ name

public function buildForm()

{

    }

controller

quote :

use Kris\LaravelFormBuilder\FormBuilder;

function :

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

View :

<!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8">   <title></title> </head> <body>   {!! form($form) !!} </body> </html>

Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/113276.html Link to the original text :https://javaforall.cn

原网站

版权声明
本文为[Full stack programmer webmaster]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071146402747.html