Title1

Title2

Title3

12-5-1 op_form

op_form程式


#################################
# 表單
#	選單關鍵字 nav_home
#################################
function op_form($sn = "") {
	global $mysqli, $smarty;

	#取得預設值
	if ($sn) {
		#編輯
		$row = get_creative_nav($sn); //取得單筆記錄
		$row['op'] = "op_update";
		$row['form_title'] = "編輯選單";
	} else {
		#新增
		$row = array();
		$row['op'] = "op_insert";
		$row['form_title'] = "新增選單";
	}

	#預設值設定
	$row['sn'] = (isset($row['sn'])) ? $row['sn'] : "";
	$row['title'] = (isset($row['title'])) ? $row['title'] : "";
	$row['enable'] = (isset($row['enable'])) ? $row['enable'] : 1;
	$row['target'] = (isset($row['target'])) ? $row['target'] : 0;
	$row['url'] = (isset($row['url'])) ? $row['url'] : "";
	$row['sort'] = (isset($row['sort'])) ? $row['sort'] : 0;
	$row['kind'] = (isset($row['kind'])) ? $row['kind'] : "nav_home";

	#把變數送至樣板
	$smarty->assign("row", $row);
}

op_form 樣板


<{if $op == "op_form"}>
  <div class="panel panel-primary">
    <div class="panel-heading"><h3 class="panel-title">選單管理 - <{$row.form_title}></h3></div>
    <div class="panel-body">
      <form role="form" action="index.php" method="post" id="myForm">        
        <div class="row">
          <div class="col-md-6">
            <div class="form-group">
              <label>標題</label>
              <input type="text" name="title" id="title" class="form-control" value="<{$row.title}>" placeholder="標題" >
            </div>
          </div>
          <div class="col-md-6">
            <div class="form-group">
              <label>網址</label>
              <input type="text" name="url" id="url" class="form-control" value="<{$row.url}>" placeholder="網址">
            </div>
          </div>
          <div class="col-md-1">
            <div class="form-group">
              <label>排序</label>
              <input type="text" name="sort" id="sort" class="form-control" value="<{$row.sort}>">
            </div>
          </div>
          <div class="col-md-2">            
            <div class="form-group">
              <label style="display:block;">外連狀態</label>
              <input type="radio" name="target" id="target_1" value="1" <{if $row.target == 1}>checked<{/if}>>
              <label for="target_1">外連</label>&nbsp;&nbsp;
              <input type="radio" name="target" id="target_0" value="0" <{if $row.target == 0}>checked<{/if}>>
              <label for="target_0">本站</label>
            </div>
          </div>
          <div class="col-md-2">            
            <div class="form-group">
              <label style="display:block;">啟用狀態</label>
              <input type="radio" name="enable" id="enable_1" value="1" <{if $row.enable == 1}>checked<{/if}>>
              <label for="enable_1">啟用</label>&nbsp;&nbsp;
              <input type="radio" name="enable" id="enable_0" value="0" <{if $row.enable == 0}>checked<{/if}>>
              <label for="enable_0">停用</label>
            </div>
          </div>
        </div>
        <hr>
        <div class="text-center">
          <input type="hidden" name="op" value="<{$row.op}>">
          <input type="hidden" name="sn" value="<{$row.sn}>">
          <input type="hidden" name="kind" value="<{$row.kind}>">

          <button type="submit" class="btn btn-primary">送出</button>
          <button type="reset" class="btn btn-danger">重設</button>
          <button type="button" class="btn btn-warning" onclick="location.href='<{$smarty.session.op_list}>'">返回</button>
        </div>
      </form>
    </div>
  </div>
<{/if}>