laraform / laraform-laravel
Laraform 社区版 (Laravel)
1.2.1
2021-06-03 07:05 UTC
Requires
- php: >=5.5.9
- hashids/hashids: ^3.0 || ^4.0
Requires (Dev)
- orchestra/testbench: ~3.0
- phpunit/phpunit: ^7.5
README
此仓库包含 Laraform 社区版的 Laravel 扩展包。
查看 laraform/laraform 仓库或 文档 了解更多详情。
安装
composer require laraform/laraform-laravel
使用
// app/Forms/MyFirstForm.php <?php namespace App\Forms; use Laraform; class MyFirstForm extends Laraform { public $schema = [ 'hello_world' => [ 'type' => 'text', 'label' => 'Hello', 'default' => 'World' ] ]; }
将表单传递到视图中
// routes/web.php Route::get('/', function () { return view('welcome', [ 'form' => app('App\Forms\MyFirstForm') ]); });
渲染
<!-- resources/views/welcome.blade.php ---> <html> <head> <!-- ... ---> <meta name="csrf-token" content="{{ csrf_token() }}"> <link rel="stylesheet" type="text/css" href="/css/app.css"> </head> <body> <div id="app"> {!! $form->render() !!} </div> <script src="/js/app.js"></script> </body> </html>
请注意,您需要 Larafrom Vue 扩展包 才能使其正常工作。