123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
-
- <link rel="stylesheet" href="__PUBLIC__/plugins/layui/css/layui.css?v={$version}" media="all">
-
- <div style="width:90%;padding:20px 5%;">
- <form class="layui-form" action="form.html">
-
- <!--隐藏参数-->
- <input type="hidden" name="id" value="{$detail.id}"/>
- <input type="hidden" name="typeid" value="{$typeid}"/>
- <input type="hidden" name="proid" value="{$proid}"/>
- <div class="layui-form-item">
- <label class="layui-form-label">名称</label>
- <div class="layui-input-block">
- <input type="text" name="name" lay-verify="title" autocomplete="off" placeholder="请输入" class="layui-input" value="{$detail.typename}">
- </div>
- </div>
-
- <div class="layui-form-item">
- <label class="layui-form-label">是否热门</label>
- <div class="layui-input-block">
- <input type="radio" name="is_hot" value="1" title="是" <?php if((int)$detail['is_hot'] === 1){
- echo 'checked=""';
- }?>>
- <input type="radio" name="is_hot" value="0" title="否" <?php if((int)$detail['is_hot'] === 0){
- echo 'checked=""';
- }?>>
- </div>
- </div>
-
- <div class="layui-form-item">
- <div class="layui-input-block">
- <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
- <!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
- </div>
- </div>
- </form>
-
- <script src="__PUBLIC__/plugins/layui/layui.js?v={$version}" charset="utf-8"></script>
- <script>
- layui.use(['form', 'layedit', 'laydate'], function(){
- var form = layui.form
- ,layer = layui.layer
- ,layedit = layui.layedit
- ,laydate = layui.laydate
- ,$ = layui.$;
-
- //日期
- laydate.render({
- elem: '#date'
- });
- laydate.render({
- elem: '#date1'
- });
-
- //创建一个编辑器
- var editIndex = layedit.build('LAY_demo_editor');
-
- //自定义验证规则
- form.verify({
- title: function(value){
- if(value.length < 1){
- return '标题至少得1个字符啊';
- }
- }
- ,pass: [
- /^[\S]{6,12}$/
- ,'密码必须6到12位,且不能出现空格'
- ]
- ,content: function(value){
- layedit.sync(editIndex);
- }
- });
-
- //监听指定开关
- form.on('switch(switchTest)', function(data){
- layer.msg('开关checked:'+ (this.checked ? 'true' : 'false'), {
- offset: '6px'
- });
- layer.tips('温馨提示:请注意开关状态的文字可以随意定义,而不仅仅是ON|OFF', data.othis)
- });
-
- //监听提交
- form.on('submit(demo1)', function(data){
- /*layer.alert(JSON.stringify(data.field), {
- title: '最终的提交信息'
- })*/
- var index = parent.layer.getFrameIndex(window.name);
- $.post("/login.php?m=admin&c=Archives&a=edit_pro_post", data.field, function (res){
- console.log(res);
- parent.layer.msg(res.msg);
- setTimeout(function(){
- parent.location.reload();
- parent.layer.close(index);
- }, 1000);
- });
- return false;
- });
-
- //表单赋值
- layui.$('#LAY-component-form-setval').on('click', function(){
- form.val('example', {
- "username": "贤心" // "name": "value"
- ,"password": "123456"
- ,"interest": 1
- ,"like[write]": true //复选框选中状态
- ,"close": true //开关状态
- ,"sex": "女"
- ,"desc": "我爱 layui"
- });
- });
-
- //表单取值
- layui.$('#LAY-component-form-getval').on('click', function(){
- var data = form.val('example');
- alert(JSON.stringify(data));
- });
-
- });
- </script>
|