<?php include $this->admin_tpl('meta', 'admin');?>
<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="<?php echo $data['name'];?>"></li>
			 <li><label><span class="c-red">*</span>表名</label><input type="text" class="input" name="tablename" value="<?php echo $data['tablename'];?>" disabled="disabled"></li>
			 <li><label>表单状态</label>
			 <span class="span_input">
			 	<label class="label_radio"><input name="disabled" type="radio" value="0" <?php if(!$data['disabled']) echo 'checked';?>> 启用</label>
			 	<label class="label_radio"><input name="disabled" type="radio" value="1" <?php if($data['disabled']) echo 'checked';?>> 禁用</label>
			 </span>
			 </li>
			 <li><label>开启验证码</label>
				<span class="span_input">
				   <label class="label_radio"><input name="check_code" type="radio" value="1" <?php if($data['check_code']) echo 'checked';?>> 是</label>
				   <label class="label_radio"><input name="check_code" type="radio" value="0" <?php if(!$data['check_code']) echo 'checked';?>> 否</label>
				</span>
			   </li>
			 <li><label>开启邮件提醒</label>
			 <span class="span_input">
			 	<label class="label_radio"><input name="sendmail" type="radio" value="0" <?php if(!$data['sendmail']) echo 'checked';?>> 否</label>
			 	<label class="label_radio"><input name="sendmail" type="radio" value="1" <?php if($data['sendmail']) echo 'checked';?>> 是</label>
				<span style="color:#898989">[请先正确配置邮箱]</span>
			 </span>
			 </li>
			 <li><label>允许游客提交表单</label>
			 <span class="span_input">
			 	<label class="label_radio"><input name="allowvisitor" type="radio" value="0" <?php if(!$data['allowvisitor']) echo 'checked';?>> 否</label>
			 	<label class="label_radio"><input name="allowvisitor" type="radio" value="1" <?php if($data['allowvisitor']) echo 'checked';?>> 是</label>
			 </span>
			 </li>
			 <li><label>表单简介</label><span class="span_input"><textarea name="description" class="textarea" style="width:400px"><?php echo $data['description'];?></textarea></span></li>
			 <li><label>显示页模板</label>
			 <span class="span_input">
				<select id="show_template" name="show_template">
					<option value="">请选择</option>
				  <?php 
				   foreach($show_temp as $key => $val){
					   $str = $data['show_template']==$key ? 'selected' : '';
					   echo '<option '.$str.' value='.$key.'>'.$val.'('.$key.')</option>';
				   }
				  ?>			
				</select>
			 </span>
			 </li>				 
			 <li><input type="hidden" name="dosubmit" value="1"><input type="hidden" name="modelid" value="<?php echo $data['modelid'];?>">
			 <input class="dosubmit w_120 btn-primary radius" type="submit" value="提交">
			 <input class="btn w_120 btn-default radius h35" type="button" value="取消" onclick="yzmcms_close()">
			</li>
		</ul>
	</form>
</div>
</article>
<?php include $this->admin_tpl('footer', 'admin');?>
<script type="text/javascript">
	function dosub(obj){
		 var reg = /^[A-Za-z]+$/;	
		 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;
		 }
		 
		if($("select[name='list_template']").val()==''){
			layer.msg('请选择列表页模板！');
			return false;
		}
		if($("select[name='show_template']").val()==''){
			layer.msg('请选择显示页模板！');
			return false;
		}		 
		 
        $.ajax({
            type: 'POST',
            url: '<?php echo U('edit');?>', 
            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>