创建表单

以 ElementUI 为例,用法如下:

use  FormBuilder\Factory\Elm;

$action = '/save.php';
$method = 'POST';

$input = Elm::input('goods_name', '商品名称')->required();
$textarea = Elm::textarea('goods_info', '商品简介');
$switch = Elm::switches('is_open', '是否开启')->activeText('开启')->inactiveText('关闭');

//创建表单
$form = Elm::form($action)->setMethod($method);

//添加组件
$form->setRule([$input, $textarea]);
$form->append($switch);

//生成表单页面
echo $formHtml = $form->view();

{warning} Iview的命名空间为FormBuilder\Factory\Iview,使用方法和 ElementUI 相同

Powered by