rachad 2012-06-25 17:11:02 3666次浏览 3条回复 0 0 0

post数据:

array(
  'validdays' => string '180' (length=3)
  'productName' => string 'asdfasd' (length=7)
  'purchaseNumber' => string 'asd' (length=3)
  'purchaseUnits' => string 'asdf' (length=4)
  'purchaseType' => string '现货/标准品' (length=16)
  'productCategory' => string '5' (length=1)
  'content' => string 'sadfasdf' (length=8)
  'address' => string '河北省,石家庄' (length=21)
  'startTime' => string '2012-06-09' (length=10)
  'endTime' => string '2012-06-06' (length=10)
  'areaId' => string '河南省,濮阳' (length=18)
  'sample' => string '0' (length=1)
  'enduting' => string '0' (length=1)
  'payType' => string '' (length=0)
  'publicMessage' => int 0
  'publicInquiry' => int 0
  'artificialInquiry' => int 0
)

验证模块:

class PublishForm extends CMyFormModel{
	public $productName;
	public $purchaseNumber;
	public $purchaseUnits;
	public $purchaseType;
	public $productCategory;
	public $content;
	public $validdays;
	public $address;
	public $areaId;
	public $startTime;
	public $endTime;
	public $sample;
	public $enduting;
	public $payType;
	public $publicMessage;
	public $publicInquiry;
	public $artificialInquiry;
	
	public function rules(){
		return array(
			array('productName,purchaseNumber,purchaseUnits,purchaseType,productCategory,content','required'),
			array('startTime','compare', 'compareAttribute' => 'endTime', 'operator' => '<', 'message' => Yii::t('yii','starttime must before endtime.')), 
			array('purchaseNumber,validdays','numerical'),
		);
	}
	
	public function attributeLabels(){
		return array(
			'productName'=>'产品名称',
			'purchaseNumber'=>'采购数量',
			'purchaseUnits'=>'采购单位',
			'purchaseType'=>'采购类型',
			'productCategory'=>'产品分类',
			'content'=>'详细描述',
		);
	}
	
}
$model = new PublisForm();
$model->attributes	= $post;
$model->validate();
var_dump($model);

结果是:

object(PublishForm)[12]
  public 'productName' => string 'asdfasd' (length=7)
  public 'purchaseNumber' => string 'asd' (length=3)
  public 'purchaseUnits' => string 'asdf' (length=4)
  public 'purchaseType' => string '现货/标准品' (length=16)
  public 'productCategory' => string '5' (length=1)
  public 'content' => string 'sadfasdf' (length=8)
  public 'validdays' => string '180' (length=3)
  public 'address' => null
  public 'areaId' => null
  public 'startTime' => string '2012-06-09' (length=10)
  public 'endTime' => null
  public 'sample' => null
  public 'enduting' => null
  public 'payType' => null
  public 'publicMessage' => null
  public 'publicInquiry' => null
  public 'artificialInquiry' => null
  private '_errors' (CModel) => 

怎么有些值都不见呢????????

您需要登录后才可以回复。登录 | 立即注册