<?php
if($request_type=='add')
{
    ?>
        <h1><font color="orange" size="+15">3.</font>新建您的自定义表单</h1>
        <h4 style="font-weight: 100">收集更多参赛者的信息</h4>
        <br/><br/>
        <div class="next">
            <center>
    <a href="index.php?c=race&action=race_add_sussess&id=<?php echo $race_id?>&request_type=<?php echo $request_type?>"> 完成发布 </a>
</center>
</div>
    <?php
}
?>
<form action="index.php?c=race&action=race_input_add&race_id=<?php echo $race_id; ?>&request_type=<?php echo $request_type?>" method="post"
      enctype="application/x-www-form-urlencoded" id="form">
	<div class="panel sky">
		<h3><i class="fa fa-pencil"></i>新增表单</h3>
		<p style="font-weight: 100">新增一列表单，收集用户更多的信息</p>
		<input type="text" placeholder="标题" name="input_title">
		<br/><br/>
		<select name="input_type" onchange = "c(this.value)">
			<option value=1>类型：文本表单</option>
			<option value=2>选择</option>
		</select><br/><br/>
		<input type="text" placeholder="请输入说明" name="instructions">
		<br/><br/>
		<div style="display:none" id="default_value_div">
		选择框默认项：例子“参数1|参数2”<br/>
			<input type="text" placeholder="选择框默认项：例子“参数1|参数2”" name="default_values" id="default_value">
		</div>
		<select name="can_null">
				<option value="0">是否必填：否</option>
				<option value="1">是否必填：是</option>
			</select>
			<br/><br/>
		<input type="submit" value="新增" class="btn_b blue" style="color: white">
	</div>
</form>
<div class="input_list_div">
<?php 
if($result)
{
	foreach($result as $row)
	{
		?>
		
		<form action="index.php?c=race&action=race_input_edit&input_type=<?php echo $row['input_type']?>&race_id=<?php echo $race_id; ?>&id=<?php echo $row['id']?>&request_type=<?php echo $request_type?>" method="post"
      enctype="application/x-www-form-urlencoded" id="form">
		<center>	<div class="panel">
		<?php
		if($row['input_type'] =='1')
		{
		?>
		<h3>[文本表单]</h3>		
		<?php
		}
		elseif($row['input_type']==2)
		{
		?>
		<h3>[选择表单]</h3>
		<?php
		}
		?>
				<table >
					<tr>
						<td>标题</td>
						<td><input type="text" placeholder="标题" name="input_title" value="<?php echo $row['input_title']?>" style="width:70%"></td>
					</tr>
					<tr>
						<td>
						说明
						</td>
						<td>
						<input type="text" placeholder="请输入说明" value="<?php echo $row['instructions']?>" name="instructions">
						</td>
					</tr>
				<?php
				if($row['input_type']==2)
				{
				?>
					<tr>
						<td>
						选择项
						</td>
						<td>
				选择框默认项：例子“参数1|参数2”<br/>
				<input type="text" placeholder="请填写默认项" name="default_values" value="<?php echo $row['default_values']?>" style="width:70%"><br/>
						</td>
					</tr>
				<?php
				}
				?>
					<tr>
						<td>是否必填</td>
						<td>
							<select name="can_null">
								<option value="0" <?php if($row['can_null']=='0'){ echo 'selected';} ?>>否</option>
								<option value="1" <?php if($row['can_null']=='1'){ echo 'selected';} ?>>是</option>
							</select>

						</td>
					</tr>
					<tr>
						<td>
						</td>
						<td><input type="submit" value="编辑" style="border:none;background:none;width:50px" ><?php
				 if($row['is_del']=='0')
				{?>
				<a href="index.php?c=race&action=race_input_del&is_del=1&race_id=<?php echo $race_id ?>&id=<?php echo $row['id'] ?>&request_type=<?php echo $request_type?>"><i class="fa fa-eye-slash"></i> </a>
				<?php }else{ ?>
				<a href="index.php?c=race&action=race_input_del&is_del=0&race_id=<?php echo $race_id ?>&id=<?php echo $row['id'] ?>&request_type=<?php echo $request_type?>"><i class="fa fa-eye"></i></a>
				<?php } ?>
						</td>
					</tr>
				</table>
			</div></center>
		</form>

		<br/>
		<?php
	}
}
?></div>
<br/>
<br/>
<br/>
<script>
	function c(v)
	{
		if(v=='2')
		{
			$("#default_value_div").css('display','block'); 
		}
	
		if(v=='1')
		{
			$("#default_value_div").css('display','none'); 
		}
	}
</script>
<style>
	.div {max-width:400px; margin-right:auto;margin-left:auto;padding:10px;text-align:center}
	input{width:80%;padding:10px; font-size:12pt}
	select{width:80%;padding:10px; font-size:12pt}
	.blue{background:#00a0df; border-radius: 4px;}
	.sky{background:#c0ebff;}
    .panel{max-width: 500px;margin-left: auto;; margin-right: auto;padding: 30px; background: #f9f9f9; border-radius: 10px; border: 1px solid #d8d8d8}
    .moren{background: orange}
    .next{position: fixed; width: 100%; bottom: 0px; height: 50px; line-height: 50px; background: #f9f9f9; border-top:1px solid #d8d8d8; z-index: 9999 }
    .next a{background: #00a0e0; color: white ; padding: 10px; border-radius: 5px;  width: 200px; }
    .input_list_div{max-width:500px; width: 100%; margin-left: auto;margin-right: auto}
</style>