Latest commit

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Form介绍:

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

特点:

  1. 没有任何依赖可独立使用

  2. 支持链式操作创建表单

  3. 支持数组配置创建表单

  4. 支持块表单

  5. 支持行内表单(支持表单表单指定默认隐藏和展示)

  6. 支持table表单

  7. 支持表单美化(默认为layui风格)且方便扩展

联系方式:

如果各位朋友觉得这个程序对你有用,若需要进一步功能扩展和二次开发可以联系我(加群找群主) metadmin/metacms/form开源交流qq群(691932844)

项目链接:

github: https://github.com/mgckid/form

gitee:https://gitee.com/mgckid/form

安装方法:

composer require mgckid/form

示例代码:

更多举例请移步demo目录去运行simple.php 查看效果。

> 运行方法 可以使用php自带的web服务器 在cmd命令行中输入以下命令开启。
php -S 127.0.0.1:88 -t D:\www\github\form\demo
注意:-t D:\www\github\form\demo 要换成你存放代码的路径 即 php -S 127.0.0.1:88 -t {你的代码绝对路径}\form\demo
> 在浏览器中 输入访问地址
http://127.0.0.1:88/index.php 测试页面集合
http://127.0.0.1:88/simple.php 对应链式操作创建块表单
http://127.0.0.1:88/simple_array.php 对应数组配置创建块表单
http://127.0.0.1:88/simple_line.php 对应行内表单
http://127.0.0.1:88/simple_table.php 对应table表单

快速使用:

链式操作创建块表单

效果图

<?phprequire__DIR__ . '/../src/Form.php';
Form::getInstance()
->form_method(Form::form_method_post)
->form_action('/')
->input_text('姓名', '姓名只能是中文', 'name', '张三')
->radio('性别', '', 'male', ['male' => '', 'female' => ''], 'male')
->checkbox('爱好', '', 'interest', ['ktv' => 'K歌', 'dance' => '跳舞', 'movie' => '看电影', 'run' => '跑步'], 'ktv,run')
->input_inline_start()
->input_text('省份', '', 'sheng', '湖北省')
->input_text('', '', 'shi', '武汉市')
->input_text('', '', 'qu', '武昌区')
->input_text('街道', '', 'jie', '紫阳路36号')
->input_inline_end()
->input_hidden('id', '1')
->input_text('user name', '', 'user', 'admin')
->input_password('password', '', 'password', '123456')
->radio('is active', '', 'is_active', [
['value' => '1', 'name' => 'active'],
['value' => '0', 'name' => 'unactive']
], 1)
->checkbox('user role', '', 'role', [
['value' => '1', 'name' => 'boss'],
['value' => '2', 'name' => 'manager'],
['value' => '3', 'name' => 'employee'],
], '1,2')
->select('user department', '', 'department', [
['value' => '1', 'name' => 'sales'],
['value' => '2', 'name' => 'hr'],
['value' => '3', 'name' => 'secured'],
], 1)
->form_class(LayuiForm::form_class_pane)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
//->input_date()//->editor()//->form_data()//->table()
->create();
?>

数组配置创建块表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
1 => array(
'title' => '用户id',
'name' => 'user_id',
'description' => '用户id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
2 => array(
'title' => '用户名',
'name' => 'username',
'description' => '用户名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '真实姓名',
'name' => 'true_name',
'description' => '真实姓名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
4 => array(
'title' => '密码',
'name' => 'password',
'description' => '密码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
5 => array(
'title' => '邮箱',
'name' => 'email',
'description' => '邮箱',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
6 => array(
'title' => '是否删除',
'name' => 'deleted',
'description' => '是否删除',
'enum' => array(
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
7 => array(
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
8 => array(
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
);
$data = array(
'id' => 2,
'user_id' => 'feac0fa3-3245-11e6-9b90-e03f49a02407',
'username' => 'admin',
'true_name' => '系统管理员',
'email' => '',
'deleted' => 0,
'created' => '2016-06-14 23:39:52',
'modified' => '2020-03-12 20:07:48',
);
\Form::getInstance()
->form_schema($init)
->form_data($data)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
->create();

行内表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
1 => array(
'title' => '代码',
'name' => 'sambol',
'description' => '代码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
2 => array(
'title' => '名称',
'name' => 'name',
'description' => '名称',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '市销率',
'name' => 'ps_ttm',
'description' => '市销率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
4 => array(
'title' => '涨跌幅',
'name' => 'percent',
'description' => '涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市净率',
'name' => 'pb_ttm',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '股价',
'name' => 'current',
'description' => '股价',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '今年涨跌幅',
'name' => 'current_year_percent',
'description' => '今年涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市值',
'name' => 'market_capital',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市盈率',
'name' => 'pe_ttm',
'description' => '市盈率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '上市日期',
'name' => 'issue_date_ts',
'description' => '上市日期',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
);
\Form::getInstance()
->input_hidden('simple_line',1)
->input_inline_start()
->form_schema($init)
->input_submit('<i class="layui-icon"></i> 搜索',
'class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"',
'class="layui-btn layui-btn-primary"',
'class="display_none_show_btn layui-btn layui-btn-normal"'
)
->input_inline_end()
->form_class(\LayuiForm::form_class_pane)
->form_method(\Form::form_method_get)
->form_action('/end.php')
->assign_display_none_field(['id', 'symbol', 'name', 'ps', 'percent', 'pb_ttm', 'current', 'current_year_percent', 'market_capital', 'pe_ttm', 'issue_date_ts',])
->create();
?>

table表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$form_init = array (
'id' =>array (
'title' => '主键',
'name' => 'id',
'description' => '主键',
'enum' =>array(),
'type' => 'hidden',
'widget_type' => '',
),
'name' =>array (
'title' => '配置名称',
'name' => 'name',
'description' => '配置名称',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'description' =>array (
'title' => '配置描述',
'name' => 'description',
'description' => '配置描述',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'input_type' =>array (
'title' => '表单类型',
'name' => 'input_type',
'description' => '表单类型',
'enum' =>array (
'hidden' => '隐藏域',
'select' => '下拉',
'radio' => '单选按钮',
'text' => '文本',
'textarea' => '多行文本',
'file' => '上传',
'none' => '非表单',
'editor' => '富文本',
'checkbox' => '复选框',
'date' => '日期',
),
'type' => 'select',
'widget_type' => '',
),
'created' =>array (
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'modified' =>array (
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'deleted' =>array (
'title' => '删除标记',
'name' => 'deleted',
'description' => '删除标记',
'enum' =>array (
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
);
$form_data=array (
0 =>
array (
'id' => 73,
'name' => 'solution_introduction',
'value' => '111',
'description' => '解决方案介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:44:40',
'modified' => '2022-03-08 00:32:08',
'deleted' => 0,
),
1 =>
array (
'id' => 72,
'name' => 'tese_product_introduction',
'value' => '222',
'description' => '特色产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:43:52',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
2 =>
array (
'id' => 71,
'name' => 'new_product_introduction',
'value' => '333',
'description' => '新产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:41:37',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
3 =>
array (
'id' => 70,
'name' => 'site_pinterest',
'value' => '',
'description' => 'Pinterest堪称图片版的Twitter链接',
'input_type' => 'text',
'created' => '2018-11-19 11:48:12',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
4 =>
array (
'id' => 69,
'name' => 'site_twitter',
'value' => '',
'description' => 'Twitter(非官方汉语通称推特)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:47:04',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
5 =>
array (
'id' => 68,
'name' => 'site_facebook',
'value' => '',
'description' => 'Facebook(脸书)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:46:07',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
6 =>
array (
'id' => 67,
'name' => 'site_google_plus',
'value' => '',
'description' => 'Google+SNS社交网站链接',
'input_type' => 'text',
'created' => '2018-11-19 11:45:26',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
7 =>
array (
'id' => 66,
'name' => 'site_linkedin',
'value' => '',
'description' => 'LinkedIn领英链接',
'input_type' => 'text',
'created' => '2018-11-19 11:43:53',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
8 =>
array (
'id' => 65,
'name' => 'site_livechat_code',
'value' => '',
'description' => 'livezilla在线客服代码',
'input_type' => 'textarea',
'created' => '2018-11-15 16:45:15',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
9 =>
array (
'id' => 64,
'name' => 'site_skype',
'value' => '',
'description' => '联系skype',
'input_type' => 'text',
'created' => '2018-11-15 16:44:40',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
)
);
\Form::getInstance()
->table('扩展配置', '', 'site_config', $form_init, $form_data)
->create();

About

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Latest commit

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Form介绍:

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

特点:

  1. 没有任何依赖可独立使用

  2. 支持链式操作创建表单

  3. 支持数组配置创建表单

  4. 支持块表单

  5. 支持行内表单(支持表单表单指定默认隐藏和展示)

  6. 支持table表单

  7. 支持表单美化(默认为layui风格)且方便扩展

联系方式:

如果各位朋友觉得这个程序对你有用,若需要进一步功能扩展和二次开发可以联系我(加群找群主) metadmin/metacms/form开源交流qq群(691932844)

项目链接:

github: https://github.com/mgckid/form

gitee:https://gitee.com/mgckid/form

安装方法:

composer require mgckid/form

示例代码:

更多举例请移步demo目录去运行simple.php 查看效果。

> 运行方法 可以使用php自带的web服务器 在cmd命令行中输入以下命令开启。
php -S 127.0.0.1:88 -t D:\www\github\form\demo
注意:-t D:\www\github\form\demo 要换成你存放代码的路径 即 php -S 127.0.0.1:88 -t {你的代码绝对路径}\form\demo
> 在浏览器中 输入访问地址
http://127.0.0.1:88/index.php 测试页面集合
http://127.0.0.1:88/simple.php 对应链式操作创建块表单
http://127.0.0.1:88/simple_array.php 对应数组配置创建块表单
http://127.0.0.1:88/simple_line.php 对应行内表单
http://127.0.0.1:88/simple_table.php 对应table表单

快速使用:

链式操作创建块表单

效果图

<?phprequire__DIR__ . '/../src/Form.php';
Form::getInstance()
->form_method(Form::form_method_post)
->form_action('/')
->input_text('姓名', '姓名只能是中文', 'name', '张三')
->radio('性别', '', 'male', ['male' => '', 'female' => ''], 'male')
->checkbox('爱好', '', 'interest', ['ktv' => 'K歌', 'dance' => '跳舞', 'movie' => '看电影', 'run' => '跑步'], 'ktv,run')
->input_inline_start()
->input_text('省份', '', 'sheng', '湖北省')
->input_text('', '', 'shi', '武汉市')
->input_text('', '', 'qu', '武昌区')
->input_text('街道', '', 'jie', '紫阳路36号')
->input_inline_end()
->input_hidden('id', '1')
->input_text('user name', '', 'user', 'admin')
->input_password('password', '', 'password', '123456')
->radio('is active', '', 'is_active', [
['value' => '1', 'name' => 'active'],
['value' => '0', 'name' => 'unactive']
], 1)
->checkbox('user role', '', 'role', [
['value' => '1', 'name' => 'boss'],
['value' => '2', 'name' => 'manager'],
['value' => '3', 'name' => 'employee'],
], '1,2')
->select('user department', '', 'department', [
['value' => '1', 'name' => 'sales'],
['value' => '2', 'name' => 'hr'],
['value' => '3', 'name' => 'secured'],
], 1)
->form_class(LayuiForm::form_class_pane)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
//->input_date()//->editor()//->form_data()//->table()
->create();
?>

数组配置创建块表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
1 => array(
'title' => '用户id',
'name' => 'user_id',
'description' => '用户id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
2 => array(
'title' => '用户名',
'name' => 'username',
'description' => '用户名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '真实姓名',
'name' => 'true_name',
'description' => '真实姓名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
4 => array(
'title' => '密码',
'name' => 'password',
'description' => '密码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
5 => array(
'title' => '邮箱',
'name' => 'email',
'description' => '邮箱',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
6 => array(
'title' => '是否删除',
'name' => 'deleted',
'description' => '是否删除',
'enum' => array(
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
7 => array(
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
8 => array(
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
);
$data = array(
'id' => 2,
'user_id' => 'feac0fa3-3245-11e6-9b90-e03f49a02407',
'username' => 'admin',
'true_name' => '系统管理员',
'email' => '',
'deleted' => 0,
'created' => '2016-06-14 23:39:52',
'modified' => '2020-03-12 20:07:48',
);
\Form::getInstance()
->form_schema($init)
->form_data($data)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
->create();

行内表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
1 => array(
'title' => '代码',
'name' => 'sambol',
'description' => '代码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
2 => array(
'title' => '名称',
'name' => 'name',
'description' => '名称',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '市销率',
'name' => 'ps_ttm',
'description' => '市销率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
4 => array(
'title' => '涨跌幅',
'name' => 'percent',
'description' => '涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市净率',
'name' => 'pb_ttm',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '股价',
'name' => 'current',
'description' => '股价',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '今年涨跌幅',
'name' => 'current_year_percent',
'description' => '今年涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市值',
'name' => 'market_capital',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市盈率',
'name' => 'pe_ttm',
'description' => '市盈率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '上市日期',
'name' => 'issue_date_ts',
'description' => '上市日期',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
);
\Form::getInstance()
->input_hidden('simple_line',1)
->input_inline_start()
->form_schema($init)
->input_submit('<i class="layui-icon"></i> 搜索',
'class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"',
'class="layui-btn layui-btn-primary"',
'class="display_none_show_btn layui-btn layui-btn-normal"'
)
->input_inline_end()
->form_class(\LayuiForm::form_class_pane)
->form_method(\Form::form_method_get)
->form_action('/end.php')
->assign_display_none_field(['id', 'symbol', 'name', 'ps', 'percent', 'pb_ttm', 'current', 'current_year_percent', 'market_capital', 'pe_ttm', 'issue_date_ts',])
->create();
?>

table表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$form_init = array (
'id' =>array (
'title' => '主键',
'name' => 'id',
'description' => '主键',
'enum' =>array(),
'type' => 'hidden',
'widget_type' => '',
),
'name' =>array (
'title' => '配置名称',
'name' => 'name',
'description' => '配置名称',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'description' =>array (
'title' => '配置描述',
'name' => 'description',
'description' => '配置描述',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'input_type' =>array (
'title' => '表单类型',
'name' => 'input_type',
'description' => '表单类型',
'enum' =>array (
'hidden' => '隐藏域',
'select' => '下拉',
'radio' => '单选按钮',
'text' => '文本',
'textarea' => '多行文本',
'file' => '上传',
'none' => '非表单',
'editor' => '富文本',
'checkbox' => '复选框',
'date' => '日期',
),
'type' => 'select',
'widget_type' => '',
),
'created' =>array (
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'modified' =>array (
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'deleted' =>array (
'title' => '删除标记',
'name' => 'deleted',
'description' => '删除标记',
'enum' =>array (
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
);
$form_data=array (
0 =>
array (
'id' => 73,
'name' => 'solution_introduction',
'value' => '111',
'description' => '解决方案介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:44:40',
'modified' => '2022-03-08 00:32:08',
'deleted' => 0,
),
1 =>
array (
'id' => 72,
'name' => 'tese_product_introduction',
'value' => '222',
'description' => '特色产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:43:52',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
2 =>
array (
'id' => 71,
'name' => 'new_product_introduction',
'value' => '333',
'description' => '新产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:41:37',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
3 =>
array (
'id' => 70,
'name' => 'site_pinterest',
'value' => '',
'description' => 'Pinterest堪称图片版的Twitter链接',
'input_type' => 'text',
'created' => '2018-11-19 11:48:12',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
4 =>
array (
'id' => 69,
'name' => 'site_twitter',
'value' => '',
'description' => 'Twitter(非官方汉语通称推特)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:47:04',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
5 =>
array (
'id' => 68,
'name' => 'site_facebook',
'value' => '',
'description' => 'Facebook(脸书)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:46:07',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
6 =>
array (
'id' => 67,
'name' => 'site_google_plus',
'value' => '',
'description' => 'Google+SNS社交网站链接',
'input_type' => 'text',
'created' => '2018-11-19 11:45:26',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
7 =>
array (
'id' => 66,
'name' => 'site_linkedin',
'value' => '',
'description' => 'LinkedIn领英链接',
'input_type' => 'text',
'created' => '2018-11-19 11:43:53',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
8 =>
array (
'id' => 65,
'name' => 'site_livechat_code',
'value' => '',
'description' => 'livezilla在线客服代码',
'input_type' => 'textarea',
'created' => '2018-11-15 16:45:15',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
9 =>
array (
'id' => 64,
'name' => 'site_skype',
'value' => '',
'description' => '联系skype',
'input_type' => 'text',
'created' => '2018-11-15 16:44:40',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
)
);
\Form::getInstance()
->table('扩展配置', '', 'site_config', $form_init, $form_data)
->create();

About

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Form介绍:

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

特点:

  1. 没有任何依赖可独立使用

  2. 支持链式操作创建表单

  3. 支持数组配置创建表单

  4. 支持块表单

  5. 支持行内表单(支持表单表单指定默认隐藏和展示)

  6. 支持table表单

  7. 支持表单美化(默认为layui风格)且方便扩展

联系方式:

如果各位朋友觉得这个程序对你有用,若需要进一步功能扩展和二次开发可以联系我(加群找群主) metadmin/metacms/form开源交流qq群(691932844)

项目链接:

github: https://github.com/mgckid/form

gitee:https://gitee.com/mgckid/form

安装方法:

composer require mgckid/form

示例代码:

更多举例请移步demo目录去运行simple.php 查看效果。

> 运行方法 可以使用php自带的web服务器 在cmd命令行中输入以下命令开启。
php -S 127.0.0.1:88 -t D:\www\github\form\demo
注意:-t D:\www\github\form\demo 要换成你存放代码的路径 即 php -S 127.0.0.1:88 -t {你的代码绝对路径}\form\demo
> 在浏览器中 输入访问地址
http://127.0.0.1:88/index.php 测试页面集合
http://127.0.0.1:88/simple.php 对应链式操作创建块表单
http://127.0.0.1:88/simple_array.php 对应数组配置创建块表单
http://127.0.0.1:88/simple_line.php 对应行内表单
http://127.0.0.1:88/simple_table.php 对应table表单

快速使用:

链式操作创建块表单

效果图

<?phprequire__DIR__ . '/../src/Form.php';
Form::getInstance()
->form_method(Form::form_method_post)
->form_action('/')
->input_text('姓名', '姓名只能是中文', 'name', '张三')
->radio('性别', '', 'male', ['male' => '', 'female' => ''], 'male')
->checkbox('爱好', '', 'interest', ['ktv' => 'K歌', 'dance' => '跳舞', 'movie' => '看电影', 'run' => '跑步'], 'ktv,run')
->input_inline_start()
->input_text('省份', '', 'sheng', '湖北省')
->input_text('', '', 'shi', '武汉市')
->input_text('', '', 'qu', '武昌区')
->input_text('街道', '', 'jie', '紫阳路36号')
->input_inline_end()
->input_hidden('id', '1')
->input_text('user name', '', 'user', 'admin')
->input_password('password', '', 'password', '123456')
->radio('is active', '', 'is_active', [
['value' => '1', 'name' => 'active'],
['value' => '0', 'name' => 'unactive']
], 1)
->checkbox('user role', '', 'role', [
['value' => '1', 'name' => 'boss'],
['value' => '2', 'name' => 'manager'],
['value' => '3', 'name' => 'employee'],
], '1,2')
->select('user department', '', 'department', [
['value' => '1', 'name' => 'sales'],
['value' => '2', 'name' => 'hr'],
['value' => '3', 'name' => 'secured'],
], 1)
->form_class(LayuiForm::form_class_pane)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
//->input_date()//->editor()//->form_data()//->table()
->create();
?>

数组配置创建块表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
1 => array(
'title' => '用户id',
'name' => 'user_id',
'description' => '用户id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
2 => array(
'title' => '用户名',
'name' => 'username',
'description' => '用户名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '真实姓名',
'name' => 'true_name',
'description' => '真实姓名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
4 => array(
'title' => '密码',
'name' => 'password',
'description' => '密码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
5 => array(
'title' => '邮箱',
'name' => 'email',
'description' => '邮箱',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
6 => array(
'title' => '是否删除',
'name' => 'deleted',
'description' => '是否删除',
'enum' => array(
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
7 => array(
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
8 => array(
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
);
$data = array(
'id' => 2,
'user_id' => 'feac0fa3-3245-11e6-9b90-e03f49a02407',
'username' => 'admin',
'true_name' => '系统管理员',
'email' => '',
'deleted' => 0,
'created' => '2016-06-14 23:39:52',
'modified' => '2020-03-12 20:07:48',
);
\Form::getInstance()
->form_schema($init)
->form_data($data)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
->create();

行内表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
1 => array(
'title' => '代码',
'name' => 'sambol',
'description' => '代码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
2 => array(
'title' => '名称',
'name' => 'name',
'description' => '名称',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '市销率',
'name' => 'ps_ttm',
'description' => '市销率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
4 => array(
'title' => '涨跌幅',
'name' => 'percent',
'description' => '涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市净率',
'name' => 'pb_ttm',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '股价',
'name' => 'current',
'description' => '股价',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '今年涨跌幅',
'name' => 'current_year_percent',
'description' => '今年涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市值',
'name' => 'market_capital',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市盈率',
'name' => 'pe_ttm',
'description' => '市盈率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '上市日期',
'name' => 'issue_date_ts',
'description' => '上市日期',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
);
\Form::getInstance()
->input_hidden('simple_line',1)
->input_inline_start()
->form_schema($init)
->input_submit('<i class="layui-icon"></i> 搜索',
'class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"',
'class="layui-btn layui-btn-primary"',
'class="display_none_show_btn layui-btn layui-btn-normal"'
)
->input_inline_end()
->form_class(\LayuiForm::form_class_pane)
->form_method(\Form::form_method_get)
->form_action('/end.php')
->assign_display_none_field(['id', 'symbol', 'name', 'ps', 'percent', 'pb_ttm', 'current', 'current_year_percent', 'market_capital', 'pe_ttm', 'issue_date_ts',])
->create();
?>

table表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$form_init = array (
'id' =>array (
'title' => '主键',
'name' => 'id',
'description' => '主键',
'enum' =>array(),
'type' => 'hidden',
'widget_type' => '',
),
'name' =>array (
'title' => '配置名称',
'name' => 'name',
'description' => '配置名称',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'description' =>array (
'title' => '配置描述',
'name' => 'description',
'description' => '配置描述',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'input_type' =>array (
'title' => '表单类型',
'name' => 'input_type',
'description' => '表单类型',
'enum' =>array (
'hidden' => '隐藏域',
'select' => '下拉',
'radio' => '单选按钮',
'text' => '文本',
'textarea' => '多行文本',
'file' => '上传',
'none' => '非表单',
'editor' => '富文本',
'checkbox' => '复选框',
'date' => '日期',
),
'type' => 'select',
'widget_type' => '',
),
'created' =>array (
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'modified' =>array (
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'deleted' =>array (
'title' => '删除标记',
'name' => 'deleted',
'description' => '删除标记',
'enum' =>array (
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
);
$form_data=array (
0 =>
array (
'id' => 73,
'name' => 'solution_introduction',
'value' => '111',
'description' => '解决方案介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:44:40',
'modified' => '2022-03-08 00:32:08',
'deleted' => 0,
),
1 =>
array (
'id' => 72,
'name' => 'tese_product_introduction',
'value' => '222',
'description' => '特色产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:43:52',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
2 =>
array (
'id' => 71,
'name' => 'new_product_introduction',
'value' => '333',
'description' => '新产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:41:37',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
3 =>
array (
'id' => 70,
'name' => 'site_pinterest',
'value' => '',
'description' => 'Pinterest堪称图片版的Twitter链接',
'input_type' => 'text',
'created' => '2018-11-19 11:48:12',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
4 =>
array (
'id' => 69,
'name' => 'site_twitter',
'value' => '',
'description' => 'Twitter(非官方汉语通称推特)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:47:04',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
5 =>
array (
'id' => 68,
'name' => 'site_facebook',
'value' => '',
'description' => 'Facebook(脸书)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:46:07',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
6 =>
array (
'id' => 67,
'name' => 'site_google_plus',
'value' => '',
'description' => 'Google+SNS社交网站链接',
'input_type' => 'text',
'created' => '2018-11-19 11:45:26',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
7 =>
array (
'id' => 66,
'name' => 'site_linkedin',
'value' => '',
'description' => 'LinkedIn领英链接',
'input_type' => 'text',
'created' => '2018-11-19 11:43:53',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
8 =>
array (
'id' => 65,
'name' => 'site_livechat_code',
'value' => '',
'description' => 'livezilla在线客服代码',
'input_type' => 'textarea',
'created' => '2018-11-15 16:45:15',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
9 =>
array (
'id' => 64,
'name' => 'site_skype',
'value' => '',
'description' => '联系skype',
'input_type' => 'text',
'created' => '2018-11-15 16:44:40',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
)
);
\Form::getInstance()
->table('扩展配置', '', 'site_config', $form_init, $form_data)
->create();

About

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Form介绍:

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

特点:

  1. 没有任何依赖可独立使用

  2. 支持链式操作创建表单

  3. 支持数组配置创建表单

  4. 支持块表单

  5. 支持行内表单(支持表单表单指定默认隐藏和展示)

  6. 支持table表单

  7. 支持表单美化(默认为layui风格)且方便扩展

联系方式:

如果各位朋友觉得这个程序对你有用,若需要进一步功能扩展和二次开发可以联系我(加群找群主) metadmin/metacms/form开源交流qq群(691932844)

项目链接:

github: https://github.com/mgckid/form

gitee:https://gitee.com/mgckid/form

安装方法:

composer require mgckid/form

示例代码:

更多举例请移步demo目录去运行simple.php 查看效果。

> 运行方法 可以使用php自带的web服务器 在cmd命令行中输入以下命令开启。
php -S 127.0.0.1:88 -t D:\www\github\form\demo
注意:-t D:\www\github\form\demo 要换成你存放代码的路径 即 php -S 127.0.0.1:88 -t {你的代码绝对路径}\form\demo
> 在浏览器中 输入访问地址
http://127.0.0.1:88/index.php 测试页面集合
http://127.0.0.1:88/simple.php 对应链式操作创建块表单
http://127.0.0.1:88/simple_array.php 对应数组配置创建块表单
http://127.0.0.1:88/simple_line.php 对应行内表单
http://127.0.0.1:88/simple_table.php 对应table表单

快速使用:

链式操作创建块表单

效果图

<?phprequire__DIR__ . '/../src/Form.php';
Form::getInstance()
->form_method(Form::form_method_post)
->form_action('/')
->input_text('姓名', '姓名只能是中文', 'name', '张三')
->radio('性别', '', 'male', ['male' => '', 'female' => ''], 'male')
->checkbox('爱好', '', 'interest', ['ktv' => 'K歌', 'dance' => '跳舞', 'movie' => '看电影', 'run' => '跑步'], 'ktv,run')
->input_inline_start()
->input_text('省份', '', 'sheng', '湖北省')
->input_text('', '', 'shi', '武汉市')
->input_text('', '', 'qu', '武昌区')
->input_text('街道', '', 'jie', '紫阳路36号')
->input_inline_end()
->input_hidden('id', '1')
->input_text('user name', '', 'user', 'admin')
->input_password('password', '', 'password', '123456')
->radio('is active', '', 'is_active', [
['value' => '1', 'name' => 'active'],
['value' => '0', 'name' => 'unactive']
], 1)
->checkbox('user role', '', 'role', [
['value' => '1', 'name' => 'boss'],
['value' => '2', 'name' => 'manager'],
['value' => '3', 'name' => 'employee'],
], '1,2')
->select('user department', '', 'department', [
['value' => '1', 'name' => 'sales'],
['value' => '2', 'name' => 'hr'],
['value' => '3', 'name' => 'secured'],
], 1)
->form_class(LayuiForm::form_class_pane)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
//->input_date()//->editor()//->form_data()//->table()
->create();
?>

数组配置创建块表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
1 => array(
'title' => '用户id',
'name' => 'user_id',
'description' => '用户id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
2 => array(
'title' => '用户名',
'name' => 'username',
'description' => '用户名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '真实姓名',
'name' => 'true_name',
'description' => '真实姓名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
4 => array(
'title' => '密码',
'name' => 'password',
'description' => '密码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
5 => array(
'title' => '邮箱',
'name' => 'email',
'description' => '邮箱',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
6 => array(
'title' => '是否删除',
'name' => 'deleted',
'description' => '是否删除',
'enum' => array(
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
7 => array(
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
8 => array(
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
);
$data = array(
'id' => 2,
'user_id' => 'feac0fa3-3245-11e6-9b90-e03f49a02407',
'username' => 'admin',
'true_name' => '系统管理员',
'email' => '',
'deleted' => 0,
'created' => '2016-06-14 23:39:52',
'modified' => '2020-03-12 20:07:48',
);
\Form::getInstance()
->form_schema($init)
->form_data($data)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
->create();

行内表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
1 => array(
'title' => '代码',
'name' => 'sambol',
'description' => '代码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
2 => array(
'title' => '名称',
'name' => 'name',
'description' => '名称',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '市销率',
'name' => 'ps_ttm',
'description' => '市销率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
4 => array(
'title' => '涨跌幅',
'name' => 'percent',
'description' => '涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市净率',
'name' => 'pb_ttm',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '股价',
'name' => 'current',
'description' => '股价',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '今年涨跌幅',
'name' => 'current_year_percent',
'description' => '今年涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市值',
'name' => 'market_capital',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市盈率',
'name' => 'pe_ttm',
'description' => '市盈率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '上市日期',
'name' => 'issue_date_ts',
'description' => '上市日期',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
);
\Form::getInstance()
->input_hidden('simple_line',1)
->input_inline_start()
->form_schema($init)
->input_submit('<i class="layui-icon"></i> 搜索',
'class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"',
'class="layui-btn layui-btn-primary"',
'class="display_none_show_btn layui-btn layui-btn-normal"'
)
->input_inline_end()
->form_class(\LayuiForm::form_class_pane)
->form_method(\Form::form_method_get)
->form_action('/end.php')
->assign_display_none_field(['id', 'symbol', 'name', 'ps', 'percent', 'pb_ttm', 'current', 'current_year_percent', 'market_capital', 'pe_ttm', 'issue_date_ts',])
->create();
?>

table表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$form_init = array (
'id' =>array (
'title' => '主键',
'name' => 'id',
'description' => '主键',
'enum' =>array(),
'type' => 'hidden',
'widget_type' => '',
),
'name' =>array (
'title' => '配置名称',
'name' => 'name',
'description' => '配置名称',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'description' =>array (
'title' => '配置描述',
'name' => 'description',
'description' => '配置描述',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'input_type' =>array (
'title' => '表单类型',
'name' => 'input_type',
'description' => '表单类型',
'enum' =>array (
'hidden' => '隐藏域',
'select' => '下拉',
'radio' => '单选按钮',
'text' => '文本',
'textarea' => '多行文本',
'file' => '上传',
'none' => '非表单',
'editor' => '富文本',
'checkbox' => '复选框',
'date' => '日期',
),
'type' => 'select',
'widget_type' => '',
),
'created' =>array (
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'modified' =>array (
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'deleted' =>array (
'title' => '删除标记',
'name' => 'deleted',
'description' => '删除标记',
'enum' =>array (
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
);
$form_data=array (
0 =>
array (
'id' => 73,
'name' => 'solution_introduction',
'value' => '111',
'description' => '解决方案介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:44:40',
'modified' => '2022-03-08 00:32:08',
'deleted' => 0,
),
1 =>
array (
'id' => 72,
'name' => 'tese_product_introduction',
'value' => '222',
'description' => '特色产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:43:52',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
2 =>
array (
'id' => 71,
'name' => 'new_product_introduction',
'value' => '333',
'description' => '新产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:41:37',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
3 =>
array (
'id' => 70,
'name' => 'site_pinterest',
'value' => '',
'description' => 'Pinterest堪称图片版的Twitter链接',
'input_type' => 'text',
'created' => '2018-11-19 11:48:12',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
4 =>
array (
'id' => 69,
'name' => 'site_twitter',
'value' => '',
'description' => 'Twitter(非官方汉语通称推特)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:47:04',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
5 =>
array (
'id' => 68,
'name' => 'site_facebook',
'value' => '',
'description' => 'Facebook(脸书)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:46:07',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
6 =>
array (
'id' => 67,
'name' => 'site_google_plus',
'value' => '',
'description' => 'Google+SNS社交网站链接',
'input_type' => 'text',
'created' => '2018-11-19 11:45:26',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
7 =>
array (
'id' => 66,
'name' => 'site_linkedin',
'value' => '',
'description' => 'LinkedIn领英链接',
'input_type' => 'text',
'created' => '2018-11-19 11:43:53',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
8 =>
array (
'id' => 65,
'name' => 'site_livechat_code',
'value' => '',
'description' => 'livezilla在线客服代码',
'input_type' => 'textarea',
'created' => '2018-11-15 16:45:15',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
9 =>
array (
'id' => 64,
'name' => 'site_skype',
'value' => '',
'description' => '联系skype',
'input_type' => 'text',
'created' => '2018-11-15 16:44:40',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
)
);
\Form::getInstance()
->table('扩展配置', '', 'site_config', $form_init, $form_data)
->create();

About

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Latest commit

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Form介绍:

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

特点:

  1. 没有任何依赖可独立使用

  2. 支持链式操作创建表单

  3. 支持数组配置创建表单

  4. 支持块表单

  5. 支持行内表单(支持表单表单指定默认隐藏和展示)

  6. 支持table表单

  7. 支持表单美化(默认为layui风格)且方便扩展

联系方式:

如果各位朋友觉得这个程序对你有用,若需要进一步功能扩展和二次开发可以联系我(加群找群主) metadmin/metacms/form开源交流qq群(691932844)

项目链接:

github: https://github.com/mgckid/form

gitee:https://gitee.com/mgckid/form

安装方法:

composer require mgckid/form

示例代码:

更多举例请移步demo目录去运行simple.php 查看效果。

> 运行方法 可以使用php自带的web服务器 在cmd命令行中输入以下命令开启。
php -S 127.0.0.1:88 -t D:\www\github\form\demo
注意:-t D:\www\github\form\demo 要换成你存放代码的路径 即 php -S 127.0.0.1:88 -t {你的代码绝对路径}\form\demo
> 在浏览器中 输入访问地址
http://127.0.0.1:88/index.php 测试页面集合
http://127.0.0.1:88/simple.php 对应链式操作创建块表单
http://127.0.0.1:88/simple_array.php 对应数组配置创建块表单
http://127.0.0.1:88/simple_line.php 对应行内表单
http://127.0.0.1:88/simple_table.php 对应table表单

快速使用:

链式操作创建块表单

效果图

<?phprequire__DIR__ . '/../src/Form.php';
Form::getInstance()
->form_method(Form::form_method_post)
->form_action('/')
->input_text('姓名', '姓名只能是中文', 'name', '张三')
->radio('性别', '', 'male', ['male' => '', 'female' => ''], 'male')
->checkbox('爱好', '', 'interest', ['ktv' => 'K歌', 'dance' => '跳舞', 'movie' => '看电影', 'run' => '跑步'], 'ktv,run')
->input_inline_start()
->input_text('省份', '', 'sheng', '湖北省')
->input_text('', '', 'shi', '武汉市')
->input_text('', '', 'qu', '武昌区')
->input_text('街道', '', 'jie', '紫阳路36号')
->input_inline_end()
->input_hidden('id', '1')
->input_text('user name', '', 'user', 'admin')
->input_password('password', '', 'password', '123456')
->radio('is active', '', 'is_active', [
['value' => '1', 'name' => 'active'],
['value' => '0', 'name' => 'unactive']
], 1)
->checkbox('user role', '', 'role', [
['value' => '1', 'name' => 'boss'],
['value' => '2', 'name' => 'manager'],
['value' => '3', 'name' => 'employee'],
], '1,2')
->select('user department', '', 'department', [
['value' => '1', 'name' => 'sales'],
['value' => '2', 'name' => 'hr'],
['value' => '3', 'name' => 'secured'],
], 1)
->form_class(LayuiForm::form_class_pane)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
//->input_date()//->editor()//->form_data()//->table()
->create();
?>

数组配置创建块表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
1 => array(
'title' => '用户id',
'name' => 'user_id',
'description' => '用户id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
2 => array(
'title' => '用户名',
'name' => 'username',
'description' => '用户名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '真实姓名',
'name' => 'true_name',
'description' => '真实姓名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
4 => array(
'title' => '密码',
'name' => 'password',
'description' => '密码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
5 => array(
'title' => '邮箱',
'name' => 'email',
'description' => '邮箱',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
6 => array(
'title' => '是否删除',
'name' => 'deleted',
'description' => '是否删除',
'enum' => array(
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
7 => array(
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
8 => array(
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
);
$data = array(
'id' => 2,
'user_id' => 'feac0fa3-3245-11e6-9b90-e03f49a02407',
'username' => 'admin',
'true_name' => '系统管理员',
'email' => '',
'deleted' => 0,
'created' => '2016-06-14 23:39:52',
'modified' => '2020-03-12 20:07:48',
);
\Form::getInstance()
->form_schema($init)
->form_data($data)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
->create();

行内表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
1 => array(
'title' => '代码',
'name' => 'sambol',
'description' => '代码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
2 => array(
'title' => '名称',
'name' => 'name',
'description' => '名称',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '市销率',
'name' => 'ps_ttm',
'description' => '市销率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
4 => array(
'title' => '涨跌幅',
'name' => 'percent',
'description' => '涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市净率',
'name' => 'pb_ttm',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '股价',
'name' => 'current',
'description' => '股价',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '今年涨跌幅',
'name' => 'current_year_percent',
'description' => '今年涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市值',
'name' => 'market_capital',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市盈率',
'name' => 'pe_ttm',
'description' => '市盈率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '上市日期',
'name' => 'issue_date_ts',
'description' => '上市日期',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
);
\Form::getInstance()
->input_hidden('simple_line',1)
->input_inline_start()
->form_schema($init)
->input_submit('<i class="layui-icon"></i> 搜索',
'class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"',
'class="layui-btn layui-btn-primary"',
'class="display_none_show_btn layui-btn layui-btn-normal"'
)
->input_inline_end()
->form_class(\LayuiForm::form_class_pane)
->form_method(\Form::form_method_get)
->form_action('/end.php')
->assign_display_none_field(['id', 'symbol', 'name', 'ps', 'percent', 'pb_ttm', 'current', 'current_year_percent', 'market_capital', 'pe_ttm', 'issue_date_ts',])
->create();
?>

table表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$form_init = array (
'id' =>array (
'title' => '主键',
'name' => 'id',
'description' => '主键',
'enum' =>array(),
'type' => 'hidden',
'widget_type' => '',
),
'name' =>array (
'title' => '配置名称',
'name' => 'name',
'description' => '配置名称',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'description' =>array (
'title' => '配置描述',
'name' => 'description',
'description' => '配置描述',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'input_type' =>array (
'title' => '表单类型',
'name' => 'input_type',
'description' => '表单类型',
'enum' =>array (
'hidden' => '隐藏域',
'select' => '下拉',
'radio' => '单选按钮',
'text' => '文本',
'textarea' => '多行文本',
'file' => '上传',
'none' => '非表单',
'editor' => '富文本',
'checkbox' => '复选框',
'date' => '日期',
),
'type' => 'select',
'widget_type' => '',
),
'created' =>array (
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'modified' =>array (
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'deleted' =>array (
'title' => '删除标记',
'name' => 'deleted',
'description' => '删除标记',
'enum' =>array (
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
);
$form_data=array (
0 =>
array (
'id' => 73,
'name' => 'solution_introduction',
'value' => '111',
'description' => '解决方案介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:44:40',
'modified' => '2022-03-08 00:32:08',
'deleted' => 0,
),
1 =>
array (
'id' => 72,
'name' => 'tese_product_introduction',
'value' => '222',
'description' => '特色产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:43:52',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
2 =>
array (
'id' => 71,
'name' => 'new_product_introduction',
'value' => '333',
'description' => '新产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:41:37',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
3 =>
array (
'id' => 70,
'name' => 'site_pinterest',
'value' => '',
'description' => 'Pinterest堪称图片版的Twitter链接',
'input_type' => 'text',
'created' => '2018-11-19 11:48:12',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
4 =>
array (
'id' => 69,
'name' => 'site_twitter',
'value' => '',
'description' => 'Twitter(非官方汉语通称推特)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:47:04',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
5 =>
array (
'id' => 68,
'name' => 'site_facebook',
'value' => '',
'description' => 'Facebook(脸书)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:46:07',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
6 =>
array (
'id' => 67,
'name' => 'site_google_plus',
'value' => '',
'description' => 'Google+SNS社交网站链接',
'input_type' => 'text',
'created' => '2018-11-19 11:45:26',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
7 =>
array (
'id' => 66,
'name' => 'site_linkedin',
'value' => '',
'description' => 'LinkedIn领英链接',
'input_type' => 'text',
'created' => '2018-11-19 11:43:53',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
8 =>
array (
'id' => 65,
'name' => 'site_livechat_code',
'value' => '',
'description' => 'livezilla在线客服代码',
'input_type' => 'textarea',
'created' => '2018-11-15 16:45:15',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
9 =>
array (
'id' => 64,
'name' => 'site_skype',
'value' => '',
'description' => '联系skype',
'input_type' => 'text',
'created' => '2018-11-15 16:44:40',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
)
);
\Form::getInstance()
->table('扩展配置', '', 'site_config', $form_init, $form_data)
->create();

About

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Form介绍:

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

特点:

  1. 没有任何依赖可独立使用

  2. 支持链式操作创建表单

  3. 支持数组配置创建表单

  4. 支持块表单

  5. 支持行内表单(支持表单表单指定默认隐藏和展示)

  6. 支持table表单

  7. 支持表单美化(默认为layui风格)且方便扩展

联系方式:

如果各位朋友觉得这个程序对你有用,若需要进一步功能扩展和二次开发可以联系我(加群找群主) metadmin/metacms/form开源交流qq群(691932844)

项目链接:

github: https://github.com/mgckid/form

gitee:https://gitee.com/mgckid/form

安装方法:

composer require mgckid/form

示例代码:

更多举例请移步demo目录去运行simple.php 查看效果。

> 运行方法 可以使用php自带的web服务器 在cmd命令行中输入以下命令开启。
php -S 127.0.0.1:88 -t D:\www\github\form\demo
注意:-t D:\www\github\form\demo 要换成你存放代码的路径 即 php -S 127.0.0.1:88 -t {你的代码绝对路径}\form\demo
> 在浏览器中 输入访问地址
http://127.0.0.1:88/index.php 测试页面集合
http://127.0.0.1:88/simple.php 对应链式操作创建块表单
http://127.0.0.1:88/simple_array.php 对应数组配置创建块表单
http://127.0.0.1:88/simple_line.php 对应行内表单
http://127.0.0.1:88/simple_table.php 对应table表单

快速使用:

链式操作创建块表单

效果图

<?phprequire__DIR__ . '/../src/Form.php';
Form::getInstance()
->form_method(Form::form_method_post)
->form_action('/')
->input_text('姓名', '姓名只能是中文', 'name', '张三')
->radio('性别', '', 'male', ['male' => '', 'female' => ''], 'male')
->checkbox('爱好', '', 'interest', ['ktv' => 'K歌', 'dance' => '跳舞', 'movie' => '看电影', 'run' => '跑步'], 'ktv,run')
->input_inline_start()
->input_text('省份', '', 'sheng', '湖北省')
->input_text('', '', 'shi', '武汉市')
->input_text('', '', 'qu', '武昌区')
->input_text('街道', '', 'jie', '紫阳路36号')
->input_inline_end()
->input_hidden('id', '1')
->input_text('user name', '', 'user', 'admin')
->input_password('password', '', 'password', '123456')
->radio('is active', '', 'is_active', [
['value' => '1', 'name' => 'active'],
['value' => '0', 'name' => 'unactive']
], 1)
->checkbox('user role', '', 'role', [
['value' => '1', 'name' => 'boss'],
['value' => '2', 'name' => 'manager'],
['value' => '3', 'name' => 'employee'],
], '1,2')
->select('user department', '', 'department', [
['value' => '1', 'name' => 'sales'],
['value' => '2', 'name' => 'hr'],
['value' => '3', 'name' => 'secured'],
], 1)
->form_class(LayuiForm::form_class_pane)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
//->input_date()//->editor()//->form_data()//->table()
->create();
?>

数组配置创建块表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
1 => array(
'title' => '用户id',
'name' => 'user_id',
'description' => '用户id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
2 => array(
'title' => '用户名',
'name' => 'username',
'description' => '用户名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '真实姓名',
'name' => 'true_name',
'description' => '真实姓名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
4 => array(
'title' => '密码',
'name' => 'password',
'description' => '密码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
5 => array(
'title' => '邮箱',
'name' => 'email',
'description' => '邮箱',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
6 => array(
'title' => '是否删除',
'name' => 'deleted',
'description' => '是否删除',
'enum' => array(
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
7 => array(
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
8 => array(
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
);
$data = array(
'id' => 2,
'user_id' => 'feac0fa3-3245-11e6-9b90-e03f49a02407',
'username' => 'admin',
'true_name' => '系统管理员',
'email' => '',
'deleted' => 0,
'created' => '2016-06-14 23:39:52',
'modified' => '2020-03-12 20:07:48',
);
\Form::getInstance()
->form_schema($init)
->form_data($data)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
->create();

行内表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
1 => array(
'title' => '代码',
'name' => 'sambol',
'description' => '代码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
2 => array(
'title' => '名称',
'name' => 'name',
'description' => '名称',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '市销率',
'name' => 'ps_ttm',
'description' => '市销率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
4 => array(
'title' => '涨跌幅',
'name' => 'percent',
'description' => '涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市净率',
'name' => 'pb_ttm',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '股价',
'name' => 'current',
'description' => '股价',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '今年涨跌幅',
'name' => 'current_year_percent',
'description' => '今年涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市值',
'name' => 'market_capital',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市盈率',
'name' => 'pe_ttm',
'description' => '市盈率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '上市日期',
'name' => 'issue_date_ts',
'description' => '上市日期',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
);
\Form::getInstance()
->input_hidden('simple_line',1)
->input_inline_start()
->form_schema($init)
->input_submit('<i class="layui-icon"></i> 搜索',
'class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"',
'class="layui-btn layui-btn-primary"',
'class="display_none_show_btn layui-btn layui-btn-normal"'
)
->input_inline_end()
->form_class(\LayuiForm::form_class_pane)
->form_method(\Form::form_method_get)
->form_action('/end.php')
->assign_display_none_field(['id', 'symbol', 'name', 'ps', 'percent', 'pb_ttm', 'current', 'current_year_percent', 'market_capital', 'pe_ttm', 'issue_date_ts',])
->create();
?>

table表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$form_init = array (
'id' =>array (
'title' => '主键',
'name' => 'id',
'description' => '主键',
'enum' =>array(),
'type' => 'hidden',
'widget_type' => '',
),
'name' =>array (
'title' => '配置名称',
'name' => 'name',
'description' => '配置名称',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'description' =>array (
'title' => '配置描述',
'name' => 'description',
'description' => '配置描述',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'input_type' =>array (
'title' => '表单类型',
'name' => 'input_type',
'description' => '表单类型',
'enum' =>array (
'hidden' => '隐藏域',
'select' => '下拉',
'radio' => '单选按钮',
'text' => '文本',
'textarea' => '多行文本',
'file' => '上传',
'none' => '非表单',
'editor' => '富文本',
'checkbox' => '复选框',
'date' => '日期',
),
'type' => 'select',
'widget_type' => '',
),
'created' =>array (
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'modified' =>array (
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'deleted' =>array (
'title' => '删除标记',
'name' => 'deleted',
'description' => '删除标记',
'enum' =>array (
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
);
$form_data=array (
0 =>
array (
'id' => 73,
'name' => 'solution_introduction',
'value' => '111',
'description' => '解决方案介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:44:40',
'modified' => '2022-03-08 00:32:08',
'deleted' => 0,
),
1 =>
array (
'id' => 72,
'name' => 'tese_product_introduction',
'value' => '222',
'description' => '特色产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:43:52',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
2 =>
array (
'id' => 71,
'name' => 'new_product_introduction',
'value' => '333',
'description' => '新产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:41:37',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
3 =>
array (
'id' => 70,
'name' => 'site_pinterest',
'value' => '',
'description' => 'Pinterest堪称图片版的Twitter链接',
'input_type' => 'text',
'created' => '2018-11-19 11:48:12',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
4 =>
array (
'id' => 69,
'name' => 'site_twitter',
'value' => '',
'description' => 'Twitter(非官方汉语通称推特)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:47:04',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
5 =>
array (
'id' => 68,
'name' => 'site_facebook',
'value' => '',
'description' => 'Facebook(脸书)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:46:07',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
6 =>
array (
'id' => 67,
'name' => 'site_google_plus',
'value' => '',
'description' => 'Google+SNS社交网站链接',
'input_type' => 'text',
'created' => '2018-11-19 11:45:26',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
7 =>
array (
'id' => 66,
'name' => 'site_linkedin',
'value' => '',
'description' => 'LinkedIn领英链接',
'input_type' => 'text',
'created' => '2018-11-19 11:43:53',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
8 =>
array (
'id' => 65,
'name' => 'site_livechat_code',
'value' => '',
'description' => 'livezilla在线客服代码',
'input_type' => 'textarea',
'created' => '2018-11-15 16:45:15',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
9 =>
array (
'id' => 64,
'name' => 'site_skype',
'value' => '',
'description' => '联系skype',
'input_type' => 'text',
'created' => '2018-11-15 16:44:40',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
)
);
\Form::getInstance()
->table('扩展配置', '', 'site_config', $form_init, $form_data)
->create();

About

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Form介绍:

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

特点:

  1. 没有任何依赖可独立使用

  2. 支持链式操作创建表单

  3. 支持数组配置创建表单

  4. 支持块表单

  5. 支持行内表单(支持表单表单指定默认隐藏和展示)

  6. 支持table表单

  7. 支持表单美化(默认为layui风格)且方便扩展

联系方式:

如果各位朋友觉得这个程序对你有用,若需要进一步功能扩展和二次开发可以联系我(加群找群主) metadmin/metacms/form开源交流qq群(691932844)

项目链接:

github: https://github.com/mgckid/form

gitee:https://gitee.com/mgckid/form

安装方法:

composer require mgckid/form

示例代码:

更多举例请移步demo目录去运行simple.php 查看效果。

> 运行方法 可以使用php自带的web服务器 在cmd命令行中输入以下命令开启。
php -S 127.0.0.1:88 -t D:\www\github\form\demo
注意:-t D:\www\github\form\demo 要换成你存放代码的路径 即 php -S 127.0.0.1:88 -t {你的代码绝对路径}\form\demo
> 在浏览器中 输入访问地址
http://127.0.0.1:88/index.php 测试页面集合
http://127.0.0.1:88/simple.php 对应链式操作创建块表单
http://127.0.0.1:88/simple_array.php 对应数组配置创建块表单
http://127.0.0.1:88/simple_line.php 对应行内表单
http://127.0.0.1:88/simple_table.php 对应table表单

快速使用:

链式操作创建块表单

效果图

<?phprequire__DIR__ . '/../src/Form.php';
Form::getInstance()
->form_method(Form::form_method_post)
->form_action('/')
->input_text('姓名', '姓名只能是中文', 'name', '张三')
->radio('性别', '', 'male', ['male' => '', 'female' => ''], 'male')
->checkbox('爱好', '', 'interest', ['ktv' => 'K歌', 'dance' => '跳舞', 'movie' => '看电影', 'run' => '跑步'], 'ktv,run')
->input_inline_start()
->input_text('省份', '', 'sheng', '湖北省')
->input_text('', '', 'shi', '武汉市')
->input_text('', '', 'qu', '武昌区')
->input_text('街道', '', 'jie', '紫阳路36号')
->input_inline_end()
->input_hidden('id', '1')
->input_text('user name', '', 'user', 'admin')
->input_password('password', '', 'password', '123456')
->radio('is active', '', 'is_active', [
['value' => '1', 'name' => 'active'],
['value' => '0', 'name' => 'unactive']
], 1)
->checkbox('user role', '', 'role', [
['value' => '1', 'name' => 'boss'],
['value' => '2', 'name' => 'manager'],
['value' => '3', 'name' => 'employee'],
], '1,2')
->select('user department', '', 'department', [
['value' => '1', 'name' => 'sales'],
['value' => '2', 'name' => 'hr'],
['value' => '3', 'name' => 'secured'],
], 1)
->form_class(LayuiForm::form_class_pane)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
//->input_date()//->editor()//->form_data()//->table()
->create();
?>

数组配置创建块表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
1 => array(
'title' => '用户id',
'name' => 'user_id',
'description' => '用户id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
2 => array(
'title' => '用户名',
'name' => 'username',
'description' => '用户名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '真实姓名',
'name' => 'true_name',
'description' => '真实姓名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
4 => array(
'title' => '密码',
'name' => 'password',
'description' => '密码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
5 => array(
'title' => '邮箱',
'name' => 'email',
'description' => '邮箱',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
6 => array(
'title' => '是否删除',
'name' => 'deleted',
'description' => '是否删除',
'enum' => array(
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
7 => array(
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
8 => array(
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
);
$data = array(
'id' => 2,
'user_id' => 'feac0fa3-3245-11e6-9b90-e03f49a02407',
'username' => 'admin',
'true_name' => '系统管理员',
'email' => '',
'deleted' => 0,
'created' => '2016-06-14 23:39:52',
'modified' => '2020-03-12 20:07:48',
);
\Form::getInstance()
->form_schema($init)
->form_data($data)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
->create();

行内表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
1 => array(
'title' => '代码',
'name' => 'sambol',
'description' => '代码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
2 => array(
'title' => '名称',
'name' => 'name',
'description' => '名称',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '市销率',
'name' => 'ps_ttm',
'description' => '市销率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
4 => array(
'title' => '涨跌幅',
'name' => 'percent',
'description' => '涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市净率',
'name' => 'pb_ttm',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '股价',
'name' => 'current',
'description' => '股价',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '今年涨跌幅',
'name' => 'current_year_percent',
'description' => '今年涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市值',
'name' => 'market_capital',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市盈率',
'name' => 'pe_ttm',
'description' => '市盈率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '上市日期',
'name' => 'issue_date_ts',
'description' => '上市日期',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
);
\Form::getInstance()
->input_hidden('simple_line',1)
->input_inline_start()
->form_schema($init)
->input_submit('<i class="layui-icon"></i> 搜索',
'class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"',
'class="layui-btn layui-btn-primary"',
'class="display_none_show_btn layui-btn layui-btn-normal"'
)
->input_inline_end()
->form_class(\LayuiForm::form_class_pane)
->form_method(\Form::form_method_get)
->form_action('/end.php')
->assign_display_none_field(['id', 'symbol', 'name', 'ps', 'percent', 'pb_ttm', 'current', 'current_year_percent', 'market_capital', 'pe_ttm', 'issue_date_ts',])
->create();
?>

table表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$form_init = array (
'id' =>array (
'title' => '主键',
'name' => 'id',
'description' => '主键',
'enum' =>array(),
'type' => 'hidden',
'widget_type' => '',
),
'name' =>array (
'title' => '配置名称',
'name' => 'name',
'description' => '配置名称',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'description' =>array (
'title' => '配置描述',
'name' => 'description',
'description' => '配置描述',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'input_type' =>array (
'title' => '表单类型',
'name' => 'input_type',
'description' => '表单类型',
'enum' =>array (
'hidden' => '隐藏域',
'select' => '下拉',
'radio' => '单选按钮',
'text' => '文本',
'textarea' => '多行文本',
'file' => '上传',
'none' => '非表单',
'editor' => '富文本',
'checkbox' => '复选框',
'date' => '日期',
),
'type' => 'select',
'widget_type' => '',
),
'created' =>array (
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'modified' =>array (
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'deleted' =>array (
'title' => '删除标记',
'name' => 'deleted',
'description' => '删除标记',
'enum' =>array (
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
);
$form_data=array (
0 =>
array (
'id' => 73,
'name' => 'solution_introduction',
'value' => '111',
'description' => '解决方案介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:44:40',
'modified' => '2022-03-08 00:32:08',
'deleted' => 0,
),
1 =>
array (
'id' => 72,
'name' => 'tese_product_introduction',
'value' => '222',
'description' => '特色产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:43:52',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
2 =>
array (
'id' => 71,
'name' => 'new_product_introduction',
'value' => '333',
'description' => '新产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:41:37',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
3 =>
array (
'id' => 70,
'name' => 'site_pinterest',
'value' => '',
'description' => 'Pinterest堪称图片版的Twitter链接',
'input_type' => 'text',
'created' => '2018-11-19 11:48:12',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
4 =>
array (
'id' => 69,
'name' => 'site_twitter',
'value' => '',
'description' => 'Twitter(非官方汉语通称推特)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:47:04',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
5 =>
array (
'id' => 68,
'name' => 'site_facebook',
'value' => '',
'description' => 'Facebook(脸书)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:46:07',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
6 =>
array (
'id' => 67,
'name' => 'site_google_plus',
'value' => '',
'description' => 'Google+SNS社交网站链接',
'input_type' => 'text',
'created' => '2018-11-19 11:45:26',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
7 =>
array (
'id' => 66,
'name' => 'site_linkedin',
'value' => '',
'description' => 'LinkedIn领英链接',
'input_type' => 'text',
'created' => '2018-11-19 11:43:53',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
8 =>
array (
'id' => 65,
'name' => 'site_livechat_code',
'value' => '',
'description' => 'livezilla在线客服代码',
'input_type' => 'textarea',
'created' => '2018-11-15 16:45:15',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
9 =>
array (
'id' => 64,
'name' => 'site_skype',
'value' => '',
'description' => '联系skype',
'input_type' => 'text',
'created' => '2018-11-15 16:44:40',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
)
);
\Form::getInstance()
->table('扩展配置', '', 'site_config', $form_init, $form_data)
->create();

About

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Latest commit

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Form介绍:

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

特点:

  1. 没有任何依赖可独立使用

  2. 支持链式操作创建表单

  3. 支持数组配置创建表单

  4. 支持块表单

  5. 支持行内表单(支持表单表单指定默认隐藏和展示)

  6. 支持table表单

  7. 支持表单美化(默认为layui风格)且方便扩展

联系方式:

如果各位朋友觉得这个程序对你有用,若需要进一步功能扩展和二次开发可以联系我(加群找群主) metadmin/metacms/form开源交流qq群(691932844)

项目链接:

github: https://github.com/mgckid/form

gitee:https://gitee.com/mgckid/form

安装方法:

composer require mgckid/form

示例代码:

更多举例请移步demo目录去运行simple.php 查看效果。

> 运行方法 可以使用php自带的web服务器 在cmd命令行中输入以下命令开启。
php -S 127.0.0.1:88 -t D:\www\github\form\demo
注意:-t D:\www\github\form\demo 要换成你存放代码的路径 即 php -S 127.0.0.1:88 -t {你的代码绝对路径}\form\demo
> 在浏览器中 输入访问地址
http://127.0.0.1:88/index.php 测试页面集合
http://127.0.0.1:88/simple.php 对应链式操作创建块表单
http://127.0.0.1:88/simple_array.php 对应数组配置创建块表单
http://127.0.0.1:88/simple_line.php 对应行内表单
http://127.0.0.1:88/simple_table.php 对应table表单

快速使用:

链式操作创建块表单

效果图

<?phprequire__DIR__ . '/../src/Form.php';
Form::getInstance()
->form_method(Form::form_method_post)
->form_action('/')
->input_text('姓名', '姓名只能是中文', 'name', '张三')
->radio('性别', '', 'male', ['male' => '', 'female' => ''], 'male')
->checkbox('爱好', '', 'interest', ['ktv' => 'K歌', 'dance' => '跳舞', 'movie' => '看电影', 'run' => '跑步'], 'ktv,run')
->input_inline_start()
->input_text('省份', '', 'sheng', '湖北省')
->input_text('', '', 'shi', '武汉市')
->input_text('', '', 'qu', '武昌区')
->input_text('街道', '', 'jie', '紫阳路36号')
->input_inline_end()
->input_hidden('id', '1')
->input_text('user name', '', 'user', 'admin')
->input_password('password', '', 'password', '123456')
->radio('is active', '', 'is_active', [
['value' => '1', 'name' => 'active'],
['value' => '0', 'name' => 'unactive']
], 1)
->checkbox('user role', '', 'role', [
['value' => '1', 'name' => 'boss'],
['value' => '2', 'name' => 'manager'],
['value' => '3', 'name' => 'employee'],
], '1,2')
->select('user department', '', 'department', [
['value' => '1', 'name' => 'sales'],
['value' => '2', 'name' => 'hr'],
['value' => '3', 'name' => 'secured'],
], 1)
->form_class(LayuiForm::form_class_pane)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
//->input_date()//->editor()//->form_data()//->table()
->create();
?>

数组配置创建块表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
1 => array(
'title' => '用户id',
'name' => 'user_id',
'description' => '用户id',
'enum' => array(),
'type' => 'hidden',
'widget_type' => '',
),
2 => array(
'title' => '用户名',
'name' => 'username',
'description' => '用户名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '真实姓名',
'name' => 'true_name',
'description' => '真实姓名',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
4 => array(
'title' => '密码',
'name' => 'password',
'description' => '密码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
5 => array(
'title' => '邮箱',
'name' => 'email',
'description' => '邮箱',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
6 => array(
'title' => '是否删除',
'name' => 'deleted',
'description' => '是否删除',
'enum' => array(
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
7 => array(
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
8 => array(
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' => array(),
'type' => 'none',
'widget_type' => 'date',
),
);
$data = array(
'id' => 2,
'user_id' => 'feac0fa3-3245-11e6-9b90-e03f49a02407',
'username' => 'admin',
'true_name' => '系统管理员',
'email' => '',
'deleted' => 0,
'created' => '2016-06-14 23:39:52',
'modified' => '2020-03-12 20:07:48',
);
\Form::getInstance()
->form_schema($init)
->form_data($data)
->input_submit('确认保存', 'class="layui-btn" lay-submit lay-filter="saveBtn"')
->create();

行内表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$init = array(
0 => array(
'title' => 'Id',
'name' => 'id',
'description' => 'Id',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
1 => array(
'title' => '代码',
'name' => 'sambol',
'description' => '代码',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
2 => array(
'title' => '名称',
'name' => 'name',
'description' => '名称',
'enum' => array(),
'type' => 'text',
'widget_type' => '',
),
3 => array(
'title' => '市销率',
'name' => 'ps_ttm',
'description' => '市销率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
4 => array(
'title' => '涨跌幅',
'name' => 'percent',
'description' => '涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市净率',
'name' => 'pb_ttm',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '股价',
'name' => 'current',
'description' => '股价',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '今年涨跌幅',
'name' => 'current_year_percent',
'description' => '今年涨跌幅',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市值',
'name' => 'market_capital',
'description' => '市净率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '市盈率',
'name' => 'pe_ttm',
'description' => '市盈率',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
array(
'title' => '上市日期',
'name' => 'issue_date_ts',
'description' => '上市日期',
'enum' => array(),
'type' => 'range',
'widget_type' => '',
),
);
\Form::getInstance()
->input_hidden('simple_line',1)
->input_inline_start()
->form_schema($init)
->input_submit('<i class="layui-icon"></i> 搜索',
'class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"',
'class="layui-btn layui-btn-primary"',
'class="display_none_show_btn layui-btn layui-btn-normal"'
)
->input_inline_end()
->form_class(\LayuiForm::form_class_pane)
->form_method(\Form::form_method_get)
->form_action('/end.php')
->assign_display_none_field(['id', 'symbol', 'name', 'ps', 'percent', 'pb_ttm', 'current', 'current_year_percent', 'market_capital', 'pe_ttm', 'issue_date_ts',])
->create();
?>

table表单

效果

<?phprequire__DIR__ . '/../src/Form.php';
$form_init = array (
'id' =>array (
'title' => '主键',
'name' => 'id',
'description' => '主键',
'enum' =>array(),
'type' => 'hidden',
'widget_type' => '',
),
'name' =>array (
'title' => '配置名称',
'name' => 'name',
'description' => '配置名称',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'description' =>array (
'title' => '配置描述',
'name' => 'description',
'description' => '配置描述',
'enum' =>array(),
'type' => 'text',
'widget_type' => '',
),
'input_type' =>array (
'title' => '表单类型',
'name' => 'input_type',
'description' => '表单类型',
'enum' =>array (
'hidden' => '隐藏域',
'select' => '下拉',
'radio' => '单选按钮',
'text' => '文本',
'textarea' => '多行文本',
'file' => '上传',
'none' => '非表单',
'editor' => '富文本',
'checkbox' => '复选框',
'date' => '日期',
),
'type' => 'select',
'widget_type' => '',
),
'created' =>array (
'title' => '创建时间',
'name' => 'created',
'description' => '创建时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'modified' =>array (
'title' => '修改时间',
'name' => 'modified',
'description' => '修改时间',
'enum' =>array(),
'type' => 'none',
'widget_type' => 'date',
),
'deleted' =>array (
'title' => '删除标记',
'name' => 'deleted',
'description' => '删除标记',
'enum' =>array (
0 => '未删除',
1 => '已删除',
),
'type' => 'none',
'widget_type' => '',
),
);
$form_data=array (
0 =>
array (
'id' => 73,
'name' => 'solution_introduction',
'value' => '111',
'description' => '解决方案介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:44:40',
'modified' => '2022-03-08 00:32:08',
'deleted' => 0,
),
1 =>
array (
'id' => 72,
'name' => 'tese_product_introduction',
'value' => '222',
'description' => '特色产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:43:52',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
2 =>
array (
'id' => 71,
'name' => 'new_product_introduction',
'value' => '333',
'description' => '新产品介绍',
'input_type' => 'textarea',
'created' => '2018-12-07 11:41:37',
'modified' => '2022-03-08 00:32:09',
'deleted' => 0,
),
3 =>
array (
'id' => 70,
'name' => 'site_pinterest',
'value' => '',
'description' => 'Pinterest堪称图片版的Twitter链接',
'input_type' => 'text',
'created' => '2018-11-19 11:48:12',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
4 =>
array (
'id' => 69,
'name' => 'site_twitter',
'value' => '',
'description' => 'Twitter(非官方汉语通称推特)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:47:04',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
5 =>
array (
'id' => 68,
'name' => 'site_facebook',
'value' => '',
'description' => 'Facebook(脸书)链接',
'input_type' => 'text',
'created' => '2018-11-19 11:46:07',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
6 =>
array (
'id' => 67,
'name' => 'site_google_plus',
'value' => '',
'description' => 'Google+SNS社交网站链接',
'input_type' => 'text',
'created' => '2018-11-19 11:45:26',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
7 =>
array (
'id' => 66,
'name' => 'site_linkedin',
'value' => '',
'description' => 'LinkedIn领英链接',
'input_type' => 'text',
'created' => '2018-11-19 11:43:53',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
8 =>
array (
'id' => 65,
'name' => 'site_livechat_code',
'value' => '',
'description' => 'livezilla在线客服代码',
'input_type' => 'textarea',
'created' => '2018-11-15 16:45:15',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
),
9 =>
array (
'id' => 64,
'name' => 'site_skype',
'value' => '',
'description' => '联系skype',
'input_type' => 'text',
'created' => '2018-11-15 16:44:40',
'modified' => '2019-04-27 14:08:07',
'deleted' => 0,
)
);
\Form::getInstance()
->table('扩展配置', '', 'site_config', $form_init, $form_data)
->create();

About

使用php编写的html动态表单生成工具类,没有任何依赖可独立使用,使用composer包管理工具安装,支持链式操作和配置创建表单,支持表单美化(默认为layui风格,支持jquery控制表单行为,只需要引入layui样式和js即可)。

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages