+ -
当前位置:首页 → 问答吧 → 求助,模型的困惑

求助,模型的困惑

时间:2011-06-08

来源:互联网

请高人帮忙解决两个模型上的困惑
1、同一字段的必须(require)和唯一(unique)怎么才能同时验证?
2、在同一模版同时使用了自动验证,自动完成,字段映射,create()方法可以写入,但不可以更新,代码如下
  1. class TypeModel extends CommonModel {
  2.         protected $_validate = array(
  3.         array('note','require','项目不能为空!'),
  4.         array('note','','项目已经存在!',0,'unique',1),
  5.         );
  6.         protected $_map = array(
  7. //        'hiddenField'=>'id',
  8.         'textfield' =>'note',
  9.         'textfield2' =>'intr',
  10.         'select3' =>'whether',
  11.         );
  12.         //日期和时间合并定入
  13.         public  $_auto = array (
  14.         array('starttime','start_time',3,'callback'),
  15.         array('endtime','end_time',3,'callback'),
  16.         );
  17.         public  function start_time(){
  18.                 $rs = $this->get_parse($_POST['datepicker'].$_POST['select']);
  19.                 return $rs;
  20.         }
  21.         public  function end_time(){
  22.                 $rs = $this->get_parse($_POST['datepicker2'].$_POST['select2']);
  23.                 return $rs;
  24.         }
  25.         public  function get_parse($act){
  26.                 import("ORG.Util.Date");
  27.                 $da = new Date();
  28.                 $rs = $da->parse($act );
  29.                 return $rs;
  30.         }

  31. }
复制代码

作者: httpwww372   发布时间: 2011-06-08

没人来指点下吗

作者: httpwww372   发布时间: 2011-06-20