public function configure()
 {
     $comm_means = UsersComm::getCommTypes();
     unset($this['id']);
     $this->widgetSchema['person_user_ref'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['entry'] = new sfWidgetFormInput();
     $this->widgetSchema['comm_type'] = new sfWidgetFormChoice(array('choices' => $comm_means));
     $this->widgetSchema['tag'] = new widgetFormTagEntry(array('choices' => Doctrine::getTable('UsersComm')->getTags($this->getObject()->getCommType())));
     $this->validatorSchema['entry'] = new sfValidatorString(array('required' => true));
     $this->validatorSchema['comm_type'] = new sfValidatorChoice(array('required' => true, 'choices' => array_keys($comm_means)));
     $this->validatorSchema['tag'] = new sfValidatorString(array('required' => false));
 }
 public function configure()
 {
     $comm_mean = UsersComm::getRegisterCommType();
     unset($this['id'], $this['tag']);
     $this->widgetSchema['person_user_ref'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['comm_type'] = new sfWidgetFormInputHidden();
     $this->setDefault('comm_type', $comm_mean);
     $this->widgetSchema['entry'] = new sfWidgetFormInput();
     $this->widgetSchema['entry']->setLabel('e-mail');
     $this->widgetSchema['entry']->setAttributes(array('class' => 'medium_size required_field'));
     $this->validatorSchema['person_user_ref'] = new sfValidatorInteger(array('required' => false));
     $this->validatorSchema['entry'] = new sfValidatorEmail(array('required' => true, 'trim' => true), array('required' => 'E-mail is required', 'invalid' => 'E-mail is not of a valid form'));
     $this->validatorSchema['comm_type'] = new sfValidatorString(array('required' => true, 'empty_value' => $comm_mean));
 }
Esempio n. 3
0
<?php

include dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(5, new lime_output_color());
$t->diag('getTagsAsArray');
$a = new UsersComm();
$t->is($a->getTagsAsArray(), array(), "By default we doesn't have a tag");
$a->setTag('pref,home,pager');
$t->is($a->getTagsAsArray(), array('Preferred', 'Home', 'Pager'), "We have 3 tags");
$a->setTag('pref');
$t->is($a->getTagsAsArray(), array('Preferred'), "We have only 1 tag");
$a->setTag('pref,home,pager');
$a->setCommType('e-mail');
$t->is($a->getTagsAsArray(), array('Preferred', 'Home'), "We have 2 tags (do not get pager)");
$a->setTag('pref,home,internet');
$t->is($a->getTagsAsArray(), array('Preferred', 'Home', 'Internet'), "We can set mail tags");