示例#1
0
 public function rules()
 {
     $video = ApartmentVideo::model();
     $panorama = ApartmentPanorama::model();
     $rules = array(array('price', 'priceValidator', 'except' => 'video_file, video_html, panorama'), array('location_id', 'locationRequired', 'except' => 'video_file, video_html, panorama'), array('title', 'i18nRequired', 'except' => 'video_file, video_html, panorama'), array('price, price_to, floor, floor_total, window_to, type, price_type, obj_type_id, city_id, activity_always', 'numerical', 'integerOnly' => true), array('square, land_square', 'numerical'), array('type', 'numerical', 'min' => 1), array('price_to', 'priceToValidator'), array('berths', 'length', 'max' => 255), array('title', 'i18nLength', 'max' => 255), array('lat, lng', 'length', 'max' => 25), array('phone', 'length', 'max' => 15), array('id', 'safe', 'on' => 'search'), array('floor', 'myFloorValidator'), array('is_price_poa', 'boolean'), array('in_currency, owner_active, num_of_rooms, is_special_offer, is_free_from, is_free_to, active, metroStations, note, period_activity, sublocation_id, region_id', 'safe'), array($this->getI18nFieldSafe(), 'safe'), array('city_id, owner_active, active, type, obj_type_id, ownerEmail, ownerUsername, popularity', 'safe', 'on' => 'search'), array('video_html', 'checkHtmlCode'), array('video_file', 'file', 'types' => $video->supportExt, 'maxSize' => $video->fileMaxSize, 'allowEmpty' => true), array('panoramaFile', 'file', 'types' => $panorama->supportedExt, 'maxSize' => $panorama->maxSize, 'tooLarge' => Yii::t('module_apartments', 'The file was larger than {size}MB. Please upload a smaller file.', array('{size}' => $panorama->maxSizeMb)), 'allowEmpty' => true));
     if (issetModule('formeditor')) {
         Yii::import('application.modules.formeditor.models.HFormEditor');
         $addRules = HFormEditor::getRulesForModel();
         $rules = CMap::mergeArray($rules, $addRules);
     }
     if (issetModule('location') && param('useLocation', 1)) {
         $rules[] = array('loc_city, loc_region, loc_country', 'safe', 'on' => 'search');
         $rules[] = array('loc_city, loc_region, loc_country', 'numerical', 'integerOnly' => true);
     }
     return $rules;
 }