code: public function saveLocation($runValidation = true, $attributeNames = null)
      {
          $location = $this->location;
          if ($location === null) {
              $location = new Location();
          }
  
          $location->country_id = $this->country_id;
          $location->region_id = $this->region_id;
          $location->city_id = $this->city_id;
          $location->state_id = $this->state_id;
          $location->address = $this->address;
          $location->postal_code = $this->postal_code;
          $location->latitude = $this->latitude;
          $location->longitude = $this->longitude;
  
          if (is_array($attributeNames)) {
              $attributesNames = array_intersect(
                      ['country_id', 'region_id', 'city_id', 'state_id', 'address', 'postal_code', 'latitude', 'longitude'], $attributesNames
              );
          }
          if (empty($attributeNames)) {
              $attributeNames = null;
          }
          if ($location->save($runValidation, $attributeNames) === false) {
              $this->addErrors($location->getErrors());
              return false;
          }
          $this->location_id = $location->id;
          return true;
      }
docs: Saves the related location object.
  
  @param bool $runValidation
  @param array $attributeNames
  @return boolean
  @see yii\db\ActiveRecord::save()