protected function saveAddress(UserAddress $address, $prefix = '') { $address->loadRequestData($this->request, $prefix); $address->countryID->set($this->request->get($prefix . 'country')); $address->stateName->set($this->request->get($prefix . 'state_text')); if ($this->request->get($prefix . 'state_select')) { $address->state->set(State::getStateByIDAndCountry($this->request->get($prefix . 'state_select'), $this->request->get($prefix . 'country'))); } else { $address->state->set(null); } $address->save(); }