public function setup()
 {
     parent::setup();
     unset($this['model'], $this['model_id'], $this['type'], $this['created_at'], $this['updated_at']);
     $this->setWidget('type', new sfWidgetFormInputHidden());
     if (class_exists("sfWidgetFormI18nChoiceCountry")) {
         $this->widgetSchema["country"] = new sfWidgetFormI18nChoiceCountry(array('culture' => sfContext::getInstance()->getUser()->getCulture()));
     } else {
         $this->widgetSchema["country"] = new sfWidgetFormI18nSelectCountry(array('culture' => sfContext::getInstance()->getUser()->getCulture()));
     }
     $this->setDefault('country', sfConfig::get('app_rt_shop_default_country', 'AU'));
     $this->widgetSchema['care_of']->setLabel('Name');
     $this->setValidator('type', new sfValidatorChoice(array('choices' => array(0 => 'billing', 1 => 'shipping'), 'required' => true)));
     $this->setValidator('care_of', new sfValidatorString(array('max_length' => 255, 'required' => true), array('required' => 'Please provide a name')));
     $this->setValidator('address_1', new sfValidatorString(array('max_length' => 255, 'required' => true), array('required' => 'Please provide an address')));
     $this->setValidator('town', new sfValidatorString(array('max_length' => 255, 'required' => true), array('required' => 'Please provide a town')));
     $this->setValidator('state', new sfValidatorString(array('max_length' => 255, 'required' => true), array('required' => 'Please provide a state')));
     $this->setValidator('postcode', new sfValidatorInteger(array('required' => true), array('required' => 'Please provide a postcode')));
     $this->setValidator('phone', new sfValidatorString(array('max_length' => 20, 'required' => false)));
     $this->widgetSchema->setNameFormat('rt_address[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
 }
 public function bind(array $taintedValues = null, array $taintedFiles = null)
 {
     parent::bind($taintedValues, $taintedFiles);
     $this->setWidget('state', new rtWidgetFormSelectRegion(array('add_empty' => '--', 'country' => $taintedValues['country'])));
 }