<?php

/* ========================================================================
 * $Id: edit.php 1643 2020-07-07 04:43:34Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# edit
#请求数据
if($MODE=='$post'){
  $id=onez()->gp('id');
  $action=onez()->gp('action');
  if($action=='data'){

    $form=$this->load('form');
    if($id){
      $T=$G['this']->data()->open('categorys')->one("id='$id'");
      $form->init($T);
    }
    $form->add(array('label'=>'商品类型','key'=>'type','type'=>'select','options'=>onez('bs.app.shipments')->product_types(),'hint'=>'','group'=>'',));
    $form->add(array('label'=>'名称','key'=>'name','type'=>'text','notempty'=>'名称不能为空','hint'=>'','group'=>'',));
    $form->add(array('label'=>'分类描述','key'=>'summary','type'=>'textarea','notempty'=>'','hint'=>'','group'=>'',));
    $form->add(array('label'=>'内容页公共头部','ptoken'=>'bs.editor','key'=>'public_header','hint'=>'','notempty'=>'','default'=>'','group'=>''),$tab);
    $form->add(array('label'=>'内容页公共尾部','ptoken'=>'bs.editor','key'=>'public_footer','hint'=>'','notempty'=>'','default'=>'','group'=>''),$tab);
    if($onez=$form->submit()){
      $onez['key1']=$onez['name'];
      $onez['key2']=$onez['type'];
      $onez['public_header']=$_REQUEST['public_header'];
      $onez['public_footer']=$_REQUEST['public_footer'];
      if($id){
        $G['this']->data()->open('categorys')->update($onez,"id='$id'");
      }else{
        $onez['userid']=$G['userid'];
  
        $G['this']->data()->open('categorys')->insert($onez);
      }
      return $this->ok('提交成功','reload2');
    }
    $form->output($A);
  }
  return;
}
$this->add(array(
  'type'=>'pageform',
  'name'=>'表单',
  'data'=>'$form',
));
?>