<?php class AddPostForm extends CFormModel { public $title; public $text; public $image; public $date; /** * Declares the validation rules. * The rules state that username and password are required, * and password needs to be authenticated. */ public function rules() { return array( 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')), ); } function attributeLabels(){ return array( 'title' => Yii::t('app', 'Title:'), 'text' => Yii::t('app', 'Text:'), 'image' => Yii::t('app', 'Image:'), ); } }