public function configure() { $unsetMe = array("id", "status_id", "date", "notes", "estimate", "acct_num", "grand_id", "other", "idr"); // unset the fields we dont want to display foreach ($unsetMe as $key) { unset($this->widgetSchema[$key]); unset($this->validatorSchema[$key]); } $this->widgetSchema['now'] = new sfWidgetFormInputHidden(); $this->widgetSchema['now']->setDefault(time()); $this->widgetSchema->setLabel('event', 'Event Name'); $this->widgetSchema->setLabel('publication_id', 'Publication'); $this->widgetSchema->setLabel('project_id', 'Project'); $this->widgetSchema['start_time'] = new sfWidgetjQueryTimepickr(); $this->widgetSchema['end_time'] = new sfWidgetjQueryTimepickr(); $this->widgetSchema['due_date'] = new sfWidgetFormJQueryDate(); $this->widgetSchema['state'] = new sfWidgetFormSelectUSState(); $this->widgetSchema['state']->setDefault("MA"); $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_email'] = new sfValidatorEmail(array('required' => true)); $this->validatorSchema['contact_phone']->setOption('required', true); $this->validatorSchema['contact_phone']->setOption('min_length', 10); $this->validatorSchema['state'] = new sfValidatorChoice(array('choices' => sfWidgetFormSelectUSState::getStateAbbreviations())); // make sure the dates are OK $this->validatorSchema->setPostValidator(new sfValidatorAnd(array(new sfValidatorSchemaCompare('start_time', sfValidatorSchemaCompare::LESS_THAN_EQUAL, 'end_time', array('throw_global_error' => true), array('invalid' => 'The start date ("%left_field%") must be before the end date! ("%right_field%")')), new sfValidatorSchemaCompare('start_time', sfValidatorSchemaCompare::GREATER_THAN, 'now', array('throw_global_error' => true), array('invalid' => 'The start date ("%left_field%") must be in the future today!'))))); }
public function configure() { $unsetMe = array("id", "status_id", "estimate", "grand_id", "other", "idr"); // unset the fields we dont want to display foreach ($unsetMe as $key) { unset($this->widgetSchema[$key]); unset($this->validatorSchema[$key]); } $this->widgetSchema['now'] = new sfWidgetFormInputHidden(); $this->widgetSchema['now']->setDefault(time()); $this->widgetSchema->setLabel('event', 'Event Name'); $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['start_time'] = new sfWidgetjQueryTimepickr(); $this->widgetSchema['end_time'] = new sfWidgetjQueryTimepickr(); $this->widgetSchema['due_date'] = new sfWidgetFormJQueryDate(); $this->widgetSchema['state'] = new sfWidgetFormSelectUSState(); $this->widgetSchema['state']->setDefault("MA"); $this->widgetSchema['notes'] = new sfWidgetFormTextarea(); $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_email'] = new sfValidatorEmail(array('required' => true)); $this->validatorSchema['contact_phone']->setOption('required', true); $this->validatorSchema['contact_phone']->setOption('min_length', 10); $this->validatorSchema['state'] = new sfValidatorChoice(array('choices' => sfWidgetFormSelectUSState::getStateAbbreviations())); // make sure the dates are OK $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, "checkJobTimes")))); }
public function configure() { $this->validatorSchema['privacy']->setOption('required', true); $this->validatorSchema['email']->setOption('required', true); $this->validatorSchema['description']->setOption('required', true); $this->widgetSchema['state'] = new sfWidgetFormSelectUSState(); $this->validatorSchema['state'] = new sfValidatorChoice(array('choices' => sfWidgetFormSelectUSState::getStateAbbreviations())); $this->validatorSchema['email'] = new sfValidatorEmail(); $this->widgetSchema['privacy'] = new sfWidgetFormChoice(array('choices' => array('web_form' => 'Hide my contact info, but show a contact form', 'show_info' => 'Show my contact info as well as a contact form'))); $neighborhoods = array('Outside Nashville' => 'Outside Nashville', 'communities' => ' ---------------', 'Antioch-Priest Lake' => 'Antioch-Priest Lake', 'Bellevue' => 'Bellevue', "Bordeaux-White's Creek" => "Bordeaux-White's Creek", 'Donelson-Hermitage' => 'Donelson-Hermitage', 'Downtown Nashville' => 'Downtown Nashville', 'East Nashville' => 'East Nashville', 'Green Hills-Midtown' => 'Green Hills-Midtown', 'Joelton' => 'Joelton', 'Madison' => 'Madison', 'North Nashville' => 'North Nashville', 'Parkwood-Union Hill' => 'Parkwood-Union Hill', 'South Nashville' => 'South Nashville', 'Southeast' => 'Southeast', 'West Nashville' => 'West Nashville'); $this->widgetSchema['neighborhood'] = new sfWidgetFormChoice(array('choices' => $neighborhoods)); // Unset invalid options unset($neighborhoods['communities']); $this->validatorSchema['neighborhood'] = new sfValidatorChoice(array('choices' => array_keys($neighborhoods))); $this->setDefault('state', 'TN'); $this->setDefault('neighborhood', 'communities'); }
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(); }
<?php /* * This file is part of the symfony package. * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../bootstrap.php'; require_once dirname(__FILE__) . '/../../lib/widget/sfWidgetFormSelectUSState.class.php'; $t = new lime_test(3, new lime_output_color()); // ->__construct() $t->diag('->__construct()'); try { new sfWidgetFormSelectUSState(); $t->pass('->__construct() does not expect a "choices" option'); } catch (RuntimeException $e) { $t->fail('->__construct() does not expect a "choices" option'); } // ->render() $t->diag('->render()'); $w = new sfWidgetFormSelectUSState(); $t->is(substr_count($w->render('state'), '<option'), 51, '->render() returns 51 select options'); $w = new sfWidgetFormSelectUSState(array('add_empty' => true)); $t->is(substr_count($w->render('state'), '<option'), 52, '->render() returns 52 select options when "add_empty" option is used');
/** * Sets the array of states. * * @param array $states */ public static function setStates(array $states) { self::$states = $states; }