/** * Evaluates the value of the user. * The return result of this method will be assigned to the current attribute(s). * @param Event $event * @return mixed the value of the user. */ protected function getValue($event) { $attribute = $this->cityAttribute; $value = $this->owner->{$attribute}; $parentAttribute = $this->provinceAttribute; $parent_id = $this->owner->{$parentAttribute}; $parent_valid = $parent_id > 0; if (is_numeric($value)) { return $value; } else { if (empty($value) or $parent_valid == FALSE) { return NULL; } else { $model = new City(['name' => $value, 'province_id' => $parent_id, 'recordStatus' => City::RECORDSTATUS_USED]); return $model->save(FALSE) ? $model->id : 0; } } }