/**
  * Run validation check.
  *
  * @param sfValidatorErrorSchema $errorSchema
  * @param array $values
  */
 private function validate($errorSchema, $values)
 {
     if ($this->isEmpty($values['address_1'])) {
         $errorSchema->addError(new sfValidatorError($this, 'required'), 'address_1');
     }
     if ($this->isEmpty($values['town'])) {
         $errorSchema->addError(new sfValidatorError($this, 'required'), 'town');
     }
     // Not all countries have regions, so this validator is conditional.
     $widget = new rtWidgetFormSelectRegion(array('country' => $values['country']));
     if (count($widget->getRegions()) > 0 && $this->isEmpty($values['state'])) {
         $errorSchema->addError(new sfValidatorError($this, 'required'), 'state');
     }
     if ($this->isEmpty($values['country'])) {
         $errorSchema->addError(new sfValidatorError($this, 'required'), 'country');
     }
     if ($this->isEmpty($values['postcode'])) {
         $errorSchema->addError(new sfValidatorError($this, 'required'), 'postcode');
     }
     if (!sfConfig::get('app_rt_account_phone_is_optional', true) && $this->isEmpty($values['phone'])) {
         $errorSchema->addError(new sfValidatorError($this, 'required'), 'phone');
     }
     if ($this->getOption('use_names')) {
         if ($this->isEmpty($values['first_name'])) {
             $errorSchema->addError(new sfValidatorError($this, 'required'), 'first_name');
         }
         if ($this->isEmpty($values['last_name'])) {
             $errorSchema->addError(new sfValidatorError($this, 'required'), 'last_name');
         }
     }
 }
 public function executeStateInput(sfWebRequest $request)
 {
     sfConfig::set('sf_debug', false);
     $this->id = $request->getParameter('id');
     $this->name = $request->getParameter('name');
     $this->country = $request->getParameter('country');
     $widget = new rtWidgetFormSelectRegion(array('add_empty' => '--', 'country' => $this->country));
     $this->options = $widget->getRegions();
 }
 /**
  * Sets the array of states.
  *
  * @param array $states
  */
 public static function setStates(array $states)
 {
     self::$states = $states;
 }