<?php include $this->admin_tpl('meta');?>
<title>添加模型 - YzmCMS内容管理系统</title>
</head>
<body>
<article class="page-container">
<div class="formdoby_normal"> 
	<form method="post" onsubmit="return dosub(this)">
		<ul>
			 <li><label><span class="c-red">*</span>模型名称：</label><input type="text" class="input" name="name" value=""></li>
			 <li><label><span class="c-red">*</span>模型表名：</label><input type="text" class="input" value="" name="tablename"></li>	
			 <li><label>模型简介：</label><span class="span_input"><textarea name="description" class="textarea" style="width:70%"></textarea></span></li>	
			 <li><label>禁用：</label>
			 <span class="span_input">
			 	<label class="label_radio"><input name="disabled" type="radio" value="1"> 是</label>
			 	<label class="label_radio"><input name="disabled" type="radio" value="0" checked> 否</label>
			 </span>
			 </li>				 
			<li>
				<input type="hidden" name="dosubmit" value="1">
				<input class="dosubmit w_120 btn-primary radius" type="submit" value="提交">
			 	<input class="btn w_120 btn-default radius" type="button" value="取消" onclick="yzmcms_close()">
			</li>
		</ul>
	</form>
</div>
</article>
<?php include $this->admin_tpl('footer');?>

<script type="text/javascript">
	function dosub(obj){
		 var reg = /^[a-zA-Z]{1}([a-zA-Z0-9]|[_]){0,19}$/;	
		 if(obj.name.value==''){
			 layer.msg('模型名称不能为空！');
			 return false;
		 }
		 if(obj.tablename.value==''){
			 layer.msg('模型表名不能为空！');
			 return false;
		 }
		 if(!reg.test(obj.tablename.value)){
			layer.msg('模型表名只能为英文或拼音！');
			return false;
		 }
        $.ajax({
            type: 'POST',
            url: '<?php echo U('add');?>', 
            data: $(obj).serialize(),
		    dataType: "json", 
            success: function (msg) {
				if(msg.status == 1){
					parent.location.reload();       
			    }else{
					layer.msg(msg.message);
				}
            }
        })		 
		return false;			 
	}
</script> 

</body>
</html>