chinese-journal/yii/protected/models/AddPostForm.php

37 lines
916 B
PHP
Raw Permalink Normal View History

2014-11-21 08:26:20 +00:00
<?php
class AddPostForm extends CFormModel
{
public $title;
public $text;
public $image;
2014-11-22 13:14:22 +00:00
public $date;
2014-11-21 08:26:20 +00:00
/**
* Declares the validation rules.
* The rules state that username and password are required,
* and password needs to be authenticated.
*/
public function rules()
{
return array(
2014-11-22 13:14:22 +00:00
array('title, text, image', 'required', 'message'=>'{attribute} ' . Yii::t('app', 'Field should not be blank')),
array('title', 'length', 'max'=>45, 'tooLong'=>'{attribute} ' . Yii::t('app', 'Line is too long')),
array('image', 'file', 'types'=>'jpg, gif, png', 'maxSize'=>8388608, 'message'=>'{attribute} ' . Yii::t('app', 'Image must be jpg, gif or png, and its size should not exceed 8 megabytes')),
2014-11-21 08:26:20 +00:00
);
}
2014-11-22 13:14:22 +00:00
function attributeLabels(){
return array(
'title' => Yii::t('app', 'Title:'),
'text' => Yii::t('app', 'Text:'),
'image' => Yii::t('app', 'Image:'),
);
}
2014-11-21 08:26:20 +00:00
}