123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <?php
- namespace App;
- require '../vendor/autoload.php';
- use FormBuilder\Annotation\Col;
- use FormBuilder\Annotation\Emit;
- use FormBuilder\Annotation\Group;
- use FormBuilder\Annotation\Validate\Required;
- use FormBuilder\Annotation\Validate\Min;
- use FormBuilder\Annotation\Validate\Range;
- use FormBuilder\Factory\Elm;
- use FormBuilder\Handle\ElmFormHandle;
- use FormBuilder\UI\Elm\Components\Rate;
- use FormBuilder\UI\Iview\Components\DatePicker;
- class GoodsForm extends ElmFormHandle
- {
- protected $action = 'save.php';
- protected $title = '测试 Handle';
- protected $fieldTitles = [
- 'start_time' => '开启时间',
- 'star' => '点赞'
- ];
- protected $scene = 'get';
- protected function getScene()
- {
- }
-
- public function goods_name_field()
- {
- return Elm::input('goods_name', '商品名称')->required();
- }
-
- public function goods_info_field()
- {
- return Elm::textarea('goods_info', '商品简介');
- }
-
- public function is_open_field()
- {
- return Elm::switches('is_open', '是否开启');
- }
-
- public function frame_field()
- {
- return Elm::frameFile('as', 'asd', 'afsdfasdf');
- }
-
- public function test_field()
- {
- return Elm::uploadFiles('aaa', 'aaa', 'bbb', [1])->required();
- }
-
- public function id_field()
- {
- return Elm::hidden('1', '1');
- }
-
- public function row_field()
- {
- return [
- 'type' => 'input',
- 'field' => 'row',
- 'title' => 'test Row',
- 'value' => '123',
- 'col' => [
- 'span' => 12
- ]
- ];
- }
-
- public function start_time_field(DatePicker $date)
- {
- return $date->required()->info('asdfasdfasdfsf');
- }
- public function starField(Rate $rate)
- {
- return $rate;
- }
- protected function getFormConfig()
- {
- $config = Elm::config();
- $config->createResetBtn()->show(true);
- return $config;
- }
- protected function getFormData()
- {
- return [
- 'goods_name' => 'goods_name123',
- 'asdf' => 'asdfafd',
- 'is_open' => '0',
- 'goods_info' => "asdf\r\nadfa",
- 'star' => 0,
- 'row' => 'adsfasdfasd'
- ];
- }
- }
- $formHtml = (new GoodsForm())->view();
- echo $formHtml;
|