/** * @inheritdoc */ public function rules() { return [[['name', 'type_id'], 'required'], [['id', 'type_id'], 'integer'], [['name', 'code'], 'string'], [['inputTimezone'], 'string'], [['inputCurrency'], 'integer'], [['inputCurrency'], function ($attribute, $params) { if (!is_null($this->{$attribute}) && empty(Currency::findOne($this->{$attribute}))) { $this->addError($attribute, Yii::t('geolocation', 'This currency does not exist.')); } }], [['listLocationIds'], function ($attribute, $params) { if (!empty($this->_listLocationIds)) { $count = self::find()->where(['id' => $this->_listLocationIds])->count(); if (empty($count) || intval($count) != count($this->_listLocationIds)) { $this->addError($attribute, Yii::t('geolocation', 'Some of these locations do not exist.')); } } }]]; }