public function setup()
 {
     parent::setup();
     $years = range(date('Y'), date('Y') + 10);
     $year_range = array();
     foreach ($years as $key => $value) {
         $year_range[$value] = $value;
     }
     // Credit card input fields
     $this->widgetSchema['cc_type'] = new sfWidgetFormSelect(array('choices' => sfConfig::get('app_rt_shop_payment_methods', array('Mastercard' => 'Mastercard', 'Visa' => 'Visa'))));
     $this->widgetSchema['cc_number'] = new sfWidgetFormInput(array(), array('class' => 'text'));
     $this->widgetSchema['cc_name'] = new sfWidgetFormInput(array(), array('class' => 'text'));
     $this->widgetSchema['cc_expire'] = new sfWidgetFormDate(array('format' => '%month%/%year%', 'years' => $year_range), array('style' => 'width:60px'));
     $this->widgetSchema['cc_verification'] = new sfWidgetFormInput(array(), array('size' => 4, 'maxlength' => 4, 'class' => 'medium text'));
     // Add labels
     $this->widgetSchema->setLabel('cc_type', "Card type:");
     $this->widgetSchema->setLabel('cc_name', "Name on Card:");
     $this->widgetSchema->setLabel('cc_number', "Credit Card number:");
     $this->widgetSchema->setLabel('cc_expire', "Expiry Date:");
     $this->widgetSchema->setLabel('cc_verification', "Verification Number:");
     // Help text
     $this->widgetSchema->setHelp('cc_number', 'Example: 4100 0000 0000 0000.');
     $this->widgetSchema->setHelp('cc_verification', 'The verification Number is a three or four-digit number on the back or front of your credit card.');
     // Validators
     $this->setValidators(array('cc_type' => new sfValidatorString(array('required' => true), array('required' => 'Please provide a credit card type.')), 'cc_name' => new sfValidatorString(array('max_length' => 100, 'required' => true), array('required' => 'Please enter the name as shown on the credit card.')), 'cc_number' => new sfValidatorString(array('required' => true), array('required' => 'Please provide a credit card number.')), 'cc_expire' => new sfValidatorPass(), 'cc_verification' => new sfValidatorString(array('min_length' => 3, 'max_length' => 4, 'required' => true), array('required' => 'Please provide a verification number.'))));
     $this->widgetSchema->setNameFormat('rt_shop_order_creditcard[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     $this->validatorSchema->setPostValidator(new rtShopCreditCardValidator());
     $this->getWidgetSchema()->setFormFormatterName(sfConfig::get('app_rt_public_form_formatter_name', 'RtList'));
 }
Exemplo n.º 2
0
 public function setUp()
 {
     $this->setWidgets(array('url_depart' => new sfWidgetFormInput(), 'navigateur' => new sfWidgetFormSelect(array('choices' => self::$navigateurs)), 'version' => new sfWidgetFormSelect(array('choices' => self::$versions)), 'robot' => new sfWidgetFormSelect(array('choices' => self::$robot)), 'vitesse_jeu' => new sfWidgetFormSelect(array('choices' => self::$vitesse_jeu)), 'environnement' => new sfWidgetFormInput()));
     $this->setValidators(array('url_depart' => new sfValidatorUrl(), 'navigateur' => new sfValidatorChoice(array('choices' => array_keys(self::$navigateurs))), 'version' => new sfValidatorChoice(array('choices' => array_keys(self::$versions))), 'robot' => new sfValidatorChoice(array('choices' => array_keys(self::$robot))), 'vitess_jeu' => new sfValidatorString(array('min_length' => 4), array('required' => 'Le champ message est obligatoire.'))));
     $this->widgetSchema->setNameFormat('playOnRobot[%s]');
     parent::setup();
 }
Exemplo n.º 3
0
 public function setup()
 {
     $this->setValidatorSchema(new sfValidatorSchema(array('id' => new sfValidatorPass(), 'page' => new sfValidatorString(array('max_length' => 255)), 'module' => new sfValidatorString(array('max_length' => 128)), 'action' => new sfValidatorString(array('max_length' => 128, 'required' => false)), 'credential' => new sfValidatorString(array('max_length' => 128, 'required' => false)), 'catch_all' => new sfValidatorPass(), 'parent' => new sfValidatorPass(), 'order' => new sfValidatorPass(), 'order_option' => new sfValidatorPass())));
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     $this->setDefault('order_option', 'below');
     parent::setup();
 }
 public function setup()
 {
     parent::setup();
     $this->setWidgets(array('username' => new sfWidgetFormInput(), 'password' => new sfWidgetFormInput(array('type' => 'password')), 'remember' => new sfWidgetFormInputCheckbox()));
     $this->setValidators(array('username' => new sfValidatorString(), 'password' => new sfValidatorString(), 'remember' => new sfValidatorBoolean()));
     $this->validatorSchema->setPostValidator(new sfGuardValidatorUser());
     $this->widgetSchema->setNameFormat('signin[%s]');
 }
Exemplo n.º 5
0
 public function setup()
 {
     $this->setWidgets(array('fields' => new sfWidgetFormChoice(array('multiple' => true, 'expanded' => true, 'choices' => $this->options['fields']))));
     $this->setValidators(array('fields' => new sfValidatorChoice(array('multiple' => true, 'choices' => array_keys($this->options['fields']), 'required' => true))));
     $this->widgetSchema->setNameFormat('csv[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     parent::setup();
 }
 public function setup()
 {
     $this->setWidgetSchema(new sfWidgetFormSchema(array('page' => new sfWidgetFormInput(), 'module' => new sfWidgetFormInput(), 'action' => new sfWidgetFormInput(), 'credential' => new sfWidgetFormInput(), 'catch_all' => new sfWidgetFormInputCheckbox())));
     $this->setValidatorSchema(new sfValidatorSchema(array('page' => new sfValidatorString(array('max_length' => 255)), 'module' => new sfValidatorString(array('max_length' => 128)), 'action' => new sfValidatorString(array('max_length' => 128)), 'credential' => new sfValidatorString(array('max_length' => 128, 'required' => false)), 'catch_all' => new sfValidatorPass())));
     $this->widgetSchema->setNameFormat('sfbreadnavedithomeform[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     parent::setup();
 }
 public function configure()
 {
     $this->setWidgets(array('email' => new sfWidgetFormInput()));
     $this->widgetSchema->setNameFormat('forgotpassword[%s]');
     $this->setValidators(array('email' => new sfValidatorEmail(array('required' => true), array('required' => 'Please enter your email'))));
     $this->widgetSchema->setNameFormat('forgotpassword[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     parent::setup();
 }
Exemplo n.º 8
0
 public function setup()
 {
     $scopes = sfBreadNavApplicationPeer::getScopeArray();
     $this->setWidgetSchema(new sfWidgetFormSchema(array('scope' => new sfWidgetFormSelect(array('choices' => $scopes), array('onchange' => 'scopeform.submit()')))));
     $this->setValidatorSchema(new sfValidatorSchema(array('scope' => new sfValidatorPass())));
     $this->widgetSchema->setNameFormat('%s');
     $this->widgetSchema->setLabel('scope', 'Active Menu');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     parent::setup();
 }
Exemplo n.º 9
0
 public function configure()
 {
     $this->setWidgets(array('captcha' => new sfWidgetFormInput()));
     $this->widgetSchema->setLabels(array('captcha' => 'Please copy the security code.'));
     $this->setValidators(array('captcha' => new sfValidatorSfCryptoCaptcha(array('required' => true, 'trim' => true), array('wrong_captcha' => 'The code you copied is not valid.', 'required' => 'You did not copy any code. Please copy the code.'))));
     $this->widgetSchema->setNameFormat('captcha_demo[%s]');
     $this->widgetSchema->setFormFormatterName('table');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     parent::setup();
 }
 public function setup()
 {
     $options = array('required' => false, 'mime_types' => 'upload_files', 'path' => sfConfig::get('sf_upload_dir'), 'mime_categories' => array('upload_files' => array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif', 'application/msword', 'application/pdf')));
     for ($i = 0; $i < 5; $i++) {
         $this->widgetSchema["file_" . $i] = new sfWidgetFormInputFile();
         $this->validatorSchema["file_" . $i] = new sfValidatorFile($options);
     }
     $this->widgetSchema->setNameFormat('jobattach[%s]');
     parent::setup();
 }
 public function setup()
 {
     parent::setup();
     $this->widgetSchema->setFormFormatterName('bootstrap');
     $this->widgetSchema->setNameFormat('contact_upload1[%s]');
     $this->setWidget('separator', new sfWidgetFormInputText());
     $this->setValidator('separator', new sfValidatorString(array('min_length' => 1, 'max_length' => 1)));
     $this->getWidgetSchema()->setDefault('separator', ',');
     $this->setWidget('file', new sfWidgetFormInputFile());
     $this->setValidator('file', new sfValidatorFile(array('required' => true)));
 }
 public function configure()
 {
     $this->setWidgets(array('email' => new sfWidgetFormInput(), 'password' => new sfWidgetFormInputPassword()));
     $this->widgetSchema->setNameFormat('login[%s]');
     $this->setValidators(array('email' => new sfValidatorString(array('required' => false)), 'password' => new sfValidatorString(array('required' => false))));
     $this->widgetSchema->setLabel('email', 'Email Or UserName');
     $this->widgetSchema->setLabel('password', 'Password');
     $this->widgetSchema->setNameFormat('users[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     parent::setup();
 }
Exemplo n.º 13
0
 public function setUp()
 {
     //        $this->getEmbeddedForm()->
     //Récupération des paramètres passés au formulaire
     $params = $this->options;
     $versions['0'] = null;
     foreach ($params['versions'] as $i => $q1) {
         $versions[$q1->id] = $q1->libelle . '    ' . $q1->getEiScenario()->nom_scenario;
     }
     $this->widgetSchema['version'] = new sfWidgetFormChoice(array('choices' => $versions));
     $this->validatorSchema['version'] = new sfValidatorChoice(array('required' => true, 'choices' => array_keys($versions)));
     $this->widgetSchema->setNameFormat('choiceVersion[%s]');
     parent::setup();
 }
Exemplo n.º 14
0
 public function configure()
 {
     parent::configure();
     $this->setWidgets(array('username' => new sfWidgetFormInput(), 'password' => new sfWidgetFormInputPassword(), 'confirmpassword' => new sfWidgetFormInputPassword(), 'firstname' => new sfWidgetFormInput(), 'lastname' => new sfWidgetFormInput(), 'email' => new sfWidgetFormInput()));
     $this->widgetSchema->setLabel('username', 'UserName');
     $this->widgetSchema->setLabel('password', 'Password');
     $this->widgetSchema->setLabel('confirmpassword', 'Confirm Password');
     $this->widgetSchema->setLabel('firstname', 'First Name');
     $this->widgetSchema->setLabel('lastname', 'Last Name');
     $this->widgetSchema->setLabel('email', 'Email');
     $this->setValidators(array('username' => new sfValidatorString(array('required' => true)), 'password' => new sfValidatorString(array('required' => true)), 'confirmpassword' => new sfValidatorString(array('required' => true)), 'firstname' => new sfValidatorString(array('required' => true)), 'lastname' => new sfValidatorString(array('required' => true)), 'email' => new sfValidatorEmail()));
     $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'confirmpassword', array(), array('invalid' => 'The two passwords must be the same.')));
     $this->widgetSchema->setNameFormat('newuser[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     parent::setup();
 }
 public function setup()
 {
     parent::setup();
     $years = range(date('Y') - 15, date('Y'));
     $options = array('format' => '%day% / %month% / %year%', 'years' => array_combine($years, $years));
     // Widgets
     $this->widgetSchema['date_from'] = new sfWidgetFormJQueryDate(array('config' => '{}', 'date_widget' => new sfWidgetFormDate($options)));
     $this->widgetSchema['date_to'] = new sfWidgetFormJQueryDate(array('config' => '{}', 'date_widget' => new sfWidgetFormDate($options)));
     // Add labels
     $this->widgetSchema->setLabel('date_from', "Date From:");
     $this->widgetSchema->setLabel('date_to', "Date To:");
     // Validators
     $this->setValidators(array('date_from' => new sfValidatorDate(array('required' => false), array()), 'date_to' => new sfValidatorDate(array('required' => false), array())));
     $this->widgetSchema->setNameFormat('rt_shop_order_report[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
 }
 public function setup()
 {
     $this->setWidgets(array('due_date_start' => new sfWidgetFormJQueryDate(), 'due_date_end' => new sfWidgetFormJQueryDate(), 'shoot_date_start' => new sfWidgetFormJQueryDate(), 'shoot_date_end' => new sfWidgetFormJQueryDate(), 'status_id' => new sfWidgetFormPropelChoice(array('model' => 'Status', 'add_empty' => true)), 'has_photo' => new sfWidgetFormInput(), 'has_client' => new sfWidgetFormInput(), 'photo_id' => new sfWidgetFormInputHidden(), 'client_id' => new sfWidgetFormInputHidden(), 'page' => new sfWidgetFormInputHidden(), 'sort' => new sfWidgetFormChoice(array("choices" => JobPeer::$LIST_VIEW_SORTABLE)), 'sort_direction' => new sfWidgetFormInputHidden()));
     $this->widgetSchema["due_date_start"]->setLabel('', '');
     $this->widgetSchema->setLabel('due_date_end', '');
     $this->widgetSchema->setLabel('shoot_date_start', '');
     $this->widgetSchema->setLabel('shoot_date_start', '');
     $this->widgetSchema->setLabel('status_id', 'Job Status');
     $this->widgetSchema->setLabel('has_photo', 'With Photographer');
     $this->widgetSchema->setLabel('has_client', 'With Client');
     $this->setValidators(array('due_date_start' => new sfValidatorDateTime(array('required' => false)), 'due_date_end' => new sfValidatorDateTime(array('required' => false)), 'shoot_date_start' => new sfValidatorDateTime(array('required' => false)), 'shoot_date_end' => new sfValidatorDateTime(array('required' => false)), 'status_id' => new sfValidatorPropelChoice(array('model' => 'Status', 'column' => 'id', 'required' => false)), 'has_photo' => new sfValidatorString(array('max_length' => 128, 'required' => false)), 'has_client' => new sfValidatorString(array('max_length' => 128, 'required' => false)), 'photo_id' => new sfValidatorString(array('max_length' => 128, 'required' => false)), 'client_id' => new sfValidatorString(array('max_length' => 128, 'required' => false)), 'page' => new sfValidatorNumber(array("required" => false)), 'sort' => new sfValidatorChoice(array("choices" => array_keys(JobPeer::$LIST_VIEW_SORTABLE))), 'sort_direction' => new sfValidatorPass(array("required" => false))));
     $this->setDefault("page", 1);
     $this->setDefault("sort_direction", 0);
     $this->widgetSchema->setNameFormat('advancedsearch[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     parent::setup();
 }
Exemplo n.º 17
0
 public function setup()
 {
     $photoTypeOptions = array();
     foreach (PhotoTypePeer::doSelect(new Criteria()) as $pt) {
         $photoTypeOptions[$pt->getName()] = $pt->getName();
     }
     $this->setWidgets(array('id' => new sfWidgetFormInputHidden(), 'project_id' => new sfWidgetFormPropelChoice(array('model' => 'Project', 'add_empty' => true)), 'publication_id' => new sfWidgetFormPropelChoice(array('model' => 'Publication', 'add_empty' => true)), 'status_id' => new sfWidgetFormPropelChoice(array('model' => 'Status', 'add_empty' => true)), 'event' => new sfWidgetFormInput(), 'date' => new sfWidgetFormJQueryDate(), 'start_time' => new sfWidgetjQueryTimepickr(array(), array("size" => 7)), 'end_time' => new sfWidgetjQueryTimepickr(array(), array("size" => 7)), 'due_date' => new sfWidgetFormJQueryDate(), 'created_at' => new sfWidgetFormDateTime(), 'street' => new sfWidgetFormInput(), 'city' => new sfWidgetFormInput(), 'state' => new sfWidgetFormSelectUSState(), 'zip' => new sfWidgetFormInput(), 'contact_name' => new sfWidgetFormInput(), 'contact_email' => new sfWidgetFormInput(), 'contact_phone' => new sfWidgetFormInput(), 'estimate' => new sfWidgetFormInput(), 'photo_type' => new sfWidgetFormChoiceMany(array("multiple" => true, "choices" => $photoTypeOptions)), 'acct_num' => new sfWidgetFormInput(), 'dept_id' => new sfWidgetFormInput(), 'grant_id' => new sfWidgetFormInput(), 'other' => new sfWidgetFormInput(), 'ques1' => new sfWidgetFormTextarea(), 'ques2' => new sfWidgetFormTextarea(), 'ques3' => new sfWidgetFormTextarea(), 'slug' => new sfWidgetFormInput(), 'user_id' => new sfWidgetFormPropelChoice(array('model' => 'sfGuardUserProfile', 'add_empty' => true)), 'name' => new sfWidgetFormInput(), 'department' => new sfWidgetFormInput(), 'address' => new sfWidgetFormInput(), 'email' => new sfWidgetFormInput(), 'phone' => new sfWidgetFormInput(), 'clientId' => new sfWidgetFormInputHidden()));
     $this->widgetSchema->setLabel('publication_id', 'Publication');
     $this->widgetSchema->setLabel('project_id', 'Project');
     $this->widgetSchema->setLabel('dept_id', 'Department Id');
     $this->widgetSchema->setLabel('acct_num', 'Account Num');
     $this->widgetSchema->setLabel('ques1', 'Please list specific photos you need, including, for group photos, number of groups and subjects in each.');
     $this->widgetSchema->setLabel('ques2', 'Please provide specific instructions for the photographer.');
     $this->widgetSchema->setLabel('ques3', 'Please describe in detail the event or story being photographed.');
     $this->widgetSchema->setLabel('estimate', 'Shoot Fee');
     $this->widgetSchema->setLabel('contact_name', 'Contact Name<span class="required">*</span>');
     $this->widgetSchema->setLabel('contact_email', 'Contact Email<span class="required">*</span>');
     $this->widgetSchema->setLabel('contact_phone', 'Contact Phone<span class="required">*</span>');
     $this->widgetSchema->setLabel('event', 'Event/Subject<span class="required">*</span>');
     $this->widgetSchema->setLabel('street', 'Street<span class="required">*</span>');
     $this->widgetSchema->setLabel('city', 'City<span class="required">*</span>');
     $this->widgetSchema->setLabel('state', 'State<span class="required">*</span>');
     $this->widgetSchema->setLabel('zip', 'Zipcode<span class="required">*</span>');
     $this->widgetSchema->setLabel('photo_type', 'Photo Type<small>Select multiple with click+crtl</small>');
     $this->widgetSchema['state']->setDefault("MA");
     $this->widgetSchema['now'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['now']->setDefault(time());
     $this->widgetSchema['clientId']->setDefault("-1");
     $this->setValidators(array('id' => new sfValidatorPropelChoice(array('model' => 'Job', 'column' => 'id', 'required' => false)), 'project_id' => new sfValidatorPropelChoice(array('model' => 'Project', 'column' => 'id', 'required' => false)), 'publication_id' => new sfValidatorPropelChoice(array('model' => 'Publication', 'column' => 'id', 'required' => false)), 'status_id' => new sfValidatorPropelChoice(array('model' => 'Status', 'column' => 'id', 'required' => false)), 'event' => new sfValidatorString(array('max_length' => 64, 'required' => false)), 'date' => new sfValidatorDate(array('required' => false)), 'start_time' => new sfValidatorDateTime(array('required' => false)), 'end_time' => new sfValidatorDateTime(array('required' => false)), 'due_date' => new sfValidatorDateTime(array('required' => false)), 'created_at' => new sfValidatorDateTime(array('required' => false)), 'street' => new sfValidatorString(array('max_length' => 64, 'required' => false)), 'city' => new sfValidatorString(array('max_length' => 64, 'required' => false)), 'state' => new sfValidatorString(array('max_length' => 64, 'required' => false)), 'zip' => new sfValidatorInteger(array('required' => false)), 'contact_name' => new sfValidatorString(array('max_length' => 45, 'required' => false)), 'contact_email' => new sfValidatorEmail(array('required' => true)), 'contact_phone' => new sfValidatorString(array('max_length' => 45, 'required' => false)), 'estimate' => new sfValidatorInteger(array('required' => false)), 'photo_type' => new sfValidatorChoice(array("choices" => $photoTypeOptions, "multiple" => true, "required" => false)), 'acct_num' => new sfValidatorString(array('max_length' => 32, 'required' => false)), 'dept_id' => new sfValidatorString(array('max_length' => 32, 'required' => false)), 'grant_id' => new sfValidatorString(array('max_length' => 32, 'required' => false)), 'other' => new sfValidatorString(array('max_length' => 255, 'required' => false)), 'ques1' => new sfValidatorString(array('required' => false)), 'ques2' => new sfValidatorString(array('required' => false)), 'ques3' => new sfValidatorString(array('required' => false)), 'slug' => new sfValidatorString(array('max_length' => 255, 'required' => false)), 'user_id' => new sfValidatorPropelChoice(array('model' => 'sfGuardUserProfile', 'column' => 'id', 'required' => false)), 'name' => new sfValidatorString(array('max_length' => 45, 'required' => false)), 'department' => new sfValidatorString(array('max_length' => 255, 'required' => false)), 'address' => new sfValidatorString(array('max_length' => 255, 'required' => false)), 'email' => new sfValidatorEmail(array('required' => false)), 'phone' => new sfValidatorString(array('max_length' => 32, 'required' => false)), 'clientId' => new sfValidatorNumber(array('required' => false))));
     $this->validatorSchema['now'] = new sfValidatorDate();
     $this->validatorSchema['event']->setOption('required', true);
     $this->validatorSchema['street']->setOption('required', true);
     $this->validatorSchema['city']->setOption('required', true);
     $this->validatorSchema['state']->setOption('required', true);
     $this->validatorSchema['zip']->setOption('required', true);
     $this->validatorSchema['contact_name']->setOption('required', true);
     $this->validatorSchema['contact_phone']->setOption('required', true);
     $this->validatorSchema['contact_phone']->setOption('min_length', 3);
     $this->validatorSchema['state'] = new sfValidatorChoice(array('choices' => sfWidgetFormSelectUSState::getStateAbbreviations()));
     $this->widgetSchema->setNameFormat('requestjob[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, "checkJobTimes"))));
     parent::setup();
 }
Exemplo n.º 18
0
 public function configure()
 {
     unset($this['created_at'], $this['updated_at']);
     $projectPackages = $this->getOption('projectPackages');
     $defPack = $this->getOption('defPack');
     $packageTab = array();
     if (count($projectPackages) > 0) {
         foreach ($projectPackages as $package) {
             $packageTab[$package->getTicketId() . '_' . $package->getTicketRef()] = $package->getName();
         }
     }
     $this->setWidgets(array('defaultPackage' => new sfWidgetFormSelect(array('choices' => $packageTab))));
     $this->setValidators(array('defaultPackage' => new sfValidatorChoice(array('choices' => array_keys($packageTab)))));
     if ($defPack != null) {
         $this->getWidget('defaultPackage')->setDefault(array('choices' => $defPack->getTicketId() . '_' . $defPack->getTicketRef()));
     }
     $this->widgetSchema['defaultPackage']->setAttribute('class', ' form-control col-lg-10 col-md-8 col-sm-5');
     $this->widgetSchema->setNameFormat('defaultPackage[%s]');
     parent::setup();
 }
 public function setup()
 {
     parent::setup();
     // Helpers
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Number'));
     // Form format
     $this->getWidgetSchema()->setFormFormatterName(sfConfig::get('app_rt_public_form_formatter_name', 'RtList'));
     // Voucher amount selection
     $options = sfConfig::get('app_rt_shop_gift_voucher_amount', array(10, 20, 25, 30, 40, 50, 75, 100, 150, 200, 300));
     // Add currency definition to amount
     $amounts = array();
     $amounts[''] = '--';
     foreach ($options as $key => $item) {
         $amounts[$item] = format_currency($item, sfConfig::get('app_rt_currency', 'USD'));
     }
     // Widgets
     $this->widgetSchema['reduction_value'] = new sfWidgetFormSelect(array('choices' => $amounts));
     $this->widgetSchema['first_name'] = new sfWidgetFormInput(array(), array());
     $this->widgetSchema['last_name'] = new sfWidgetFormInput(array(), array());
     $this->widgetSchema['email_address'] = new sfWidgetFormInput(array(), array());
     $this->widgetSchema['message'] = new sfWidgetFormTextarea(array(), array());
     // Validators
     $this->setValidator('reduction_value', new sfValidatorChoice(array('choices' => array_keys($amounts), 'required' => true), array('required' => 'Please make a selection')));
     $this->setValidator('first_name', new sfValidatorString(array('required' => true), array('required' => 'Please provide a first name')));
     $this->setValidator('last_name', new sfValidatorString(array('required' => true), array('required' => 'Please provide a last name')));
     $this->setValidator('email_address', new sfValidatorEmail(array('required' => true), array('required' => 'Please provide a valid email address')));
     $this->setValidator('message', new sfValidatorString(array('required' => false, 'max_length' => 255), array('max_length' => 'Message is too long (%max_length% characters max.)')));
     // Add labels
     $this->widgetSchema->setLabel('reduction_value', "Gift Voucher Amount");
     $this->widgetSchema->setLabel('first_name', "Recipient First Name");
     $this->widgetSchema->setLabel('last_name', "Recipient Last Name");
     $this->widgetSchema->setLabel('email_address', "Recipient Email");
     // Help texts
     $this->widgetSchema->setHelp('first_name', 'Required');
     $this->widgetSchema->setHelp('last_name', 'Required');
     $this->widgetSchema->setHelp('email_address', 'Required - The voucher will be sent here');
     $this->widgetSchema->setNameFormat('rt_shop_voucher[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
 }
Exemplo n.º 20
0
 public function configure()
 {
     if (isset($this->options['competition'])) {
         $countries = Doctrine::getTable('Competition')->getCountries($this->options['competition']);
     } else {
         $countries = Doctrine::getTable('User')->getCountries();
     }
     $this->setWidgets(array('handle' => new sfWidgetFormInput(array(), array('class' => 'inputtext', 'style' => 'width:243px')), 'country' => new sfWidgetFormSelect(array('choices' => $countries), array('style' => 'width:250px'))));
     $this->setValidators(array('country' => new sfValidatorString(array('max_length' => 200, 'required' => false)), 'handle' => new sfValidatorString(array('max_length' => 200, 'required' => false))));
     for ($i = 0; $i < $this->options['questions']; $i++) {
         $l = chr(65 + floor($i / 2)) . ($i % 2 == 0 ? '1' : '2');
         $this->setWidget('question_' . $i, new sfWidgetFormInputCheckbox(array('value_attribute_value' => '1', 'label' => $l)));
         $this->setValidator('question_' . $i, new sfValidatorString(array('required' => false)));
     }
     $this->setWidget('fb_users', new sfWidgetFormInputCheckbox(array('value_attribute_value' => '1', 'label' => 'Only Registered Users')));
     $this->setValidator('fb_users', new sfValidatorString(array('required' => false)));
     $this->setWidget('results', new sfWidgetFormSelect(array('choices' => array('50' => '50 results per page', '100' => '100 results per page', '150' => '150 results per page'))));
     $this->setValidator('results', new sfValidatorString(array('required' => false)));
     $this->widgetSchema->setNameFormat('filter[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     parent::setup();
 }
 public function setup()
 {
     parent::setup();
     $select = array();
     $select_key = array();
     $this->widgetSchema->setFormFormatterName('bootstrap');
     $this->widgetSchema->setNameFormat('contact_upload2[%s]');
     $this->setWidget('separator', new sfWidgetFormInputHidden());
     $this->setValidator('separator', new sfValidatorString(array('min_length' => 1, 'max_length' => 1)));
     //    $this->getWidgetSchema()->setDefault('separator', ',');
     $this->setWidget('separator2', new sfWidgetFormInputText());
     $this->setValidator('separator2', new sfValidatorString(array('min_length' => 1, 'max_length' => 1)));
     $this->getWidgetSchema()->setDefault('separator2', '|');
     $this->getWidgetSchema()->setLabel('separator2', 'Separator inside fields');
     $this->setWidget('female', new sfWidgetFormInputText());
     $this->setValidator('female', new sfValidatorString(array('min_length' => 1)));
     $this->getWidgetSchema()->setDefault('female', 'female');
     $this->setWidget('male', new sfWidgetFormInputText());
     $this->setValidator('male', new sfValidatorString(array('min_length' => 1)));
     $this->getWidgetSchema()->setDefault('male', 'male');
     $ml = $this->getOption('MailingList');
     if ($ml instanceof MailingList) {
         $substs = $ml->getSubstFields();
         ksort($substs);
         foreach ($substs as $subst) {
             $this->setWidget('field_' . $subst['id'], new sfWidgetFormChoice(array('choices' => $select)));
             $this->setValidator('field_' . $subst['id'], new sfValidatorChoice(array('choices' => $select_key)));
             $this->getWidgetSchema()->setLabel('field_' . $subst['id'], $subst['name']);
         }
     }
     $this->getWidgetSchema()->setHelp('field_country', 'Must be encoded with 2 letter ISO code.');
     $this->setWidget('language', new sfWidgetFormChoice(array('label' => 'Language', 'choices' => $select)));
     $this->setValidator('language', new sfValidatorChoice(array('choices' => $select_key, 'required' => false)));
     $this->getWidgetSchema()->setHelp('language', 'The following ISO codes are allowed: ' . implode(', ', LanguageTable::getInstance()->fetchLanguageIds()));
     $this->setWidget('file', new sfWidgetFormInputHidden());
     $this->setValidator('file', new sfValidatorRegex(array('pattern' => ContactUploadStep1Form::FILE_PATTERN)));
 }