
<title>表单元素</title>

<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>组件</cite></a>
    <a><cite>表单</cite></a>
    <a><cite>表单元素</cite></a>
  </div>
</div>

<style>
/* 这段样式只是用于演示 */

</style>

<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md6">
      <div class="layui-card">
        <div class="layui-card-header">输入框</div>
        <div class="layui-card-body layui-row layui-col-space10 layui-form">
          <div class="layui-col-md12">
            <input type="text" name="title" placeholder="请输入标题" autocomplete="off" class="layui-input">
          </div>
          <div class="layui-col-md6">
            <input type="text" name="title" placeholder="用户名" autocomplete="off" class="layui-input" lay-affix="clear">
          </div>
          <div class="layui-col-md6">
            <input type="password" name="title" placeholder="密码" autocomplete="off" class="layui-input" lay-affix="eye">
          </div>
          <div class="layui-col-xs6">
            <input type="number" lay-affix="number" placeholder="设置 step 为 0.01" step="0.01" class="layui-input">
          </div>
          <div class="layui-col-xs6">
            <input type="number" lay-affix="number" placeholder="设置 step,min,max" step="10" min="0" max="100" class="layui-input">
          </div>
          <div class="layui-col-xs6">
            <input type="number" lay-affix="number" readonly placeholder="不允许输入状态" class="layui-input">
          </div>
          <div class="layui-col-xs6">
            <input type="number" lay-affix="number" disabled placeholder="禁用状态" class="layui-input">
          </div>
          <div class="layui-col-md4">
            <div class="layui-input-wrap">
              <div class="layui-input-prefix">
                <i class="layui-icon layui-icon-username"></i>
              </div>
              <input type="text" placeholder="带前缀" class="layui-input">
            </div>
          </div>
          <div class="layui-col-md4">
            <div class="layui-input-wrap">
              <input type="text" placeholder="带后缀" class="layui-input">
              <div class="layui-input-suffix">
                <i class="layui-icon layui-icon-more-vertical"></i>
              </div>
            </div>
          </div>
          <div class="layui-col-md4">
            <div class="layui-input-wrap">
              <div class="layui-input-prefix">
                <i class="layui-icon layui-icon-date"></i>
              </div>
              <input type="text" placeholder="带前缀和后缀" class="layui-input">
              <div class="layui-input-suffix">
                <i class="layui-icon layui-icon-down"></i>
              </div>
            </div>
          </div>
          <div class="layui-col-md4">
            <div class="layui-input-wrap">
              <div class="layui-input-prefix layui-input-split">
                <i class="layui-icon layui-icon-password"></i>
              </div>
              <input type="password" placeholder="带前缀加分隔框" class="layui-input">
            </div>
          </div>
          <div class="layui-col-md4">
            <div class="layui-input-wrap">
              <input type="text" placeholder="带后缀加分隔框" class="layui-input">
              <div class="layui-input-suffix layui-input-split">
                <i class="layui-icon layui-icon-down"></i>
              </div>
            </div>
          </div>
          <div class="layui-col-md4">
            <div class="layui-input-wrap">
              <div class="layui-input-prefix layui-input-split">
                <i class="layui-icon layui-icon-date"></i>
              </div>
              <input type="text" placeholder="带前缀和后缀加分割框" class="layui-input">
              <div class="layui-input-suffix layui-input-split">
                <i class="layui-icon layui-icon-down"></i>
              </div>
            </div>
          </div>
          <div class="layui-col-md6">
            <div class="layui-input-wrap">
              <div class="layui-input-prefix">
                <i class="layui-icon layui-icon-location"></i>
              </div>
              <input type="text" placeholder="带前缀无分割框和后缀有分割框" class="layui-input">
              <div class="layui-input-suffix layui-input-split">
                <i class="layui-icon layui-icon-edit"></i>
              </div>
            </div>
          </div>
          <div class="layui-col-md6">
            <div class="layui-input-wrap">
              <div class="layui-input-prefix layui-input-split">
                <i class="layui-icon layui-icon-location"></i>
              </div>
              <input type="text" placeholder="带前缀有分割框和后缀无分割框" class="layui-input">
              <div class="layui-input-suffix">
                <i class="layui-icon layui-icon-edit"></i>
              </div>
            </div>
          </div>
          <div class="layui-col-md4">
            <div class="layui-input-wrap">
              <div class="layui-input-prefix">
                <i class="layui-icon layui-icon-form"></i>
              </div>
              <select>
                <option value="">放置 select 元素</option>
                <option value="北京">北京</option>
                <option value="上海">上海</option>
                <option value="广州">广州</option>
                <option value="深圳">深圳</option>
              </select>
            </div>
          </div>
        </div>
      </div>
      <div class="layui-card layui-form" lay-filter="component-form-element">
        <div class="layui-card-header">复选框</div>
        <div class="layui-card-body layui-row layui-col-space10">
          <div class="layui-col-md12">
            <input type="checkbox" name="" title="写作" checked>
            <input type="checkbox" name="" title="发呆"> 
            <input type="checkbox" name="" title="禁用" disabled> 
          </div>
          <div class="layui-col-md12">
            <input type="checkbox" name="" title="写作" lay-skin="primary" checked>
            <input type="checkbox" name="" title="发呆" lay-skin="primary"> 
            <input type="checkbox" name="" title="禁用" lay-skin="primary" disabled> 
            <input type="checkbox" name="" lay-skin="primary"> 
          </div>
        </div>
      </div>
      <div class="layui-card layui-form" lay-filter="component-form-element">
        <div class="layui-card-header">开关</div>
        <div class="layui-card-body layui-row layui-col-space10">
          <div class="layui-col-md12">
            <input type="checkbox" name="xxx" lay-skin="switch">
            <input type="checkbox" name="yyy" lay-skin="switch" lay-text="ON|OFF" checked>
            <input type="checkbox" name="zzz" lay-skin="switch" lay-text="开启|关闭">
            <input type="checkbox" name="aaa" lay-skin="switch" disabled>
          </div>
        </div>
      </div>
      <div class="layui-card layui-form" lay-filter="component-form-element">
        <div class="layui-card-header">单选框</div>
        <div class="layui-card-body layui-row layui-col-space10">
          <div class="layui-col-md12">
            <input type="radio" name="sex" value="nan" title="男">
            <input type="radio" name="sex" value="nv" title="女" checked>
            <input type="radio" name="sex" value="" title="中性" disabled>
          </div>
        </div>
      </div>
    </div>
    <div class="layui-col-md6">
      <div class="layui-card layui-form" lay-filter="component-form-element">
        <div class="layui-card-header">下拉选择框</div>
        <div class="layui-card-body layui-row layui-col-space10">
          <div class="layui-col-md6">
            <select name="city" lay-verify="">
              <option value="">请选择一个城市</option>
              <option value="010">北京</option>
              <option value="021">上海</option>
              <option value="0571">杭州</option>
            </select>
          </div>
          <div class="layui-col-md6">
            <select name="city" lay-verify="">
              <option value="010">北京</option>
              <option value="021" disabled>上海（禁用效果）</option>
              <option value="0571" selected>杭州</option>
            </select> 
          </div>
          <div class="layui-col-md6">
            <select name="quiz">
              <option value="">请选择</option>
              <optgroup label="城市记忆">
                <option value="你工作的第一个城市">你工作的第一个城市？</option>
              </optgroup>
              <optgroup label="学生时代">
                <option value="你的工号">你的工号？</option>
                <option value="你最喜欢的老师">你最喜欢的老师？</option>
              </optgroup>
            </select>
          </div>
          <div class="layui-col-md6">
            <select name="city" lay-verify="required" lay-search>
              <option value="">带搜索的选择框</option>
              <option value="1">layer</option>
              <option value="2">form</option>
              <option value="3">layim</option>
              <option value="4">element</option>
              <option value="5">laytpl</option>
              <option value="6">upload</option>
              <option value="7">laydate</option>
              <option value="8">laypage</option>
              <option value="9">flow</option>
              <option value="10">util</option>
              <option value="11">code</option>
              <option value="12">tree</option>
              <option value="13">layedit</option>
              <option value="14">nav</option>
              <option value="15">tab</option>
              <option value="16">table</option>
              <option value="17">select</option>
              <option value="18">checkbox</option>
              <option value="19">switch</option>
              <option value="20">radio</option>
            </select>
          </div>
          <div class="layui-col-md12">
            <select name="city" lay-verify="">
              <option value="">请选择一个城市</option>
              <option value="010">北京</option>
              <option value="021">上海</option>
              <option value="0571">杭州</option>
            </select>
          </div>
        </div>
      </div>
      <div class="layui-card">
        <div class="layui-card-header">响应式组合</div>
        <div class="layui-card-body">
          <form class="layui-form" action="" lay-filter="component-form-element">
            <div class="layui-row layui-col-space10 layui-form-item">
              <div class="layui-col-lg6">
                <label class="layui-form-label">员工姓名：</label>
                <div class="layui-input-block">
                  <input type="text" name="fullname" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-col-lg6">
                <label class="layui-form-label">技术工种：</label>
                <div class="layui-input-block">
                  <select name="type" lay-verify="required" lay-filter="aihao">
                    <option value=""></option>
                    <option value="0">前端工程师</option>
                    <option value="1">Node.js工程师</option>
                    <option value="2">PHP工程师</option>
                    <option value="3">Java工程师</option>
                    <option value="4">运维</option>
                    <option value="4">视觉设计师</option>
                  </select>
                </div>
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">兴趣爱好：</label>
              <div class="layui-input-block">
                <input type="checkbox" name="interest[write]" title="写作">
                <input type="checkbox" name="interest[read]" title="阅读">
                <input type="checkbox" name="interest[code]" title="代码" checked>
                <input type="checkbox" name="interest[dreaming]" title="做梦">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">是否婚姻：</label>
              <div class="layui-input-block">
                <input type="checkbox" name="marriage" lay-skin="switch" lay-text="是|否">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">所属职称：</label>
              <div class="layui-input-block">
                <input type="radio" name="role" value="" title="经理">
                <input type="radio" name="role" value="" title="主管">
                <input type="radio" name="role" value="" title="码农" checked>
                <input type="radio" name="role" value="" title="端水">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">其它信息：</label>
              <div class="layui-input-block">
                <textarea name="other" placeholder="文本域" class="layui-textarea"></textarea>
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label"> </label>
              <div class="layui-input-block">
                <input type="checkbox" name="agreement" title="同意" lay-skin="primary" checked>
              </div>
            </div>
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="component-form-element">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>

<script>
layui.use(['admin', 'form'], function(){
  var $ = layui.$
  ,admin = layui.admin
  ,element = layui.element
  ,form = layui.form;
  
  form.render();
  element.render('breadcrumb', 'breadcrumb');
  
  form.on('submit(component-form-element)', function(data){
    layer.alert(layui.util.escape(JSON.stringify(data.field)));
    return false;
  });
});
</script>