protected function addField($name) { switch ($name) { case 'authorizedFormOfName': $this->form->setValidator('authorizedFormOfName', new sfValidatorString()); $this->form->setWidget('authorizedFormOfName', new sfWidgetFormSelect(array('choices' => array()))); break; case 'type': $this->form->setDefault('type', $this->context->routing->generate(null, array(QubitTerm::getById(QubitTerm::DONOR_ID), 'module' => 'term'))); $this->form->setValidator('type', new sfValidatorString()); $this->form->setWidget('type', new sfWidgetFormInputHidden()); break; case 'countryCode': $this->form->setValidator('countryCode', new sfValidatorI18nChoiceCountry()); $this->form->setWidget('countryCode', new sfWidgetFormI18nChoiceCountry(array('add_empty' => true, 'culture' => $this->context->user->getCulture()))); break; case 'city': case 'contactPerson': case 'email': case 'postalCode': case 'region': case 'streetAddress': case 'telephone': $this->form->setValidator($name, new sfValidatorString()); $this->form->setWidget($name, new sfWidgetFormInput()); default: return parent::addField($name); } }
protected function addField($name) { switch ($name) { case 'type': $this->form->setValidator('type', new sfValidatorString(array('required' => true))); $choices = array(); $choices[null] = null; foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACTOR_RELATION_TYPE_ID) as $item) { $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item; } $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => $choices))); break; default: return parent::addField($name); } }