public function configure()
 {
     $this->useFields(array('is_physical', 'family_name', 'activity_date_to', 'activity_date_from'));
     $this->addPagerItems();
     $this->widgetSchema['family_name'] = new sfWidgetFormInput();
     $this->widgetSchema['is_physical'] = new sfWidgetFormInputHidden();
     $this->setDefault('is_physical', true);
     $yearsKeyVal = range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')));
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal) . '/12/31'));
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $maxDate->setStart(false);
     $this->widgetSchema['activity_date_from'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'from_date'));
     $this->widgetSchema['activity_date_to'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'to_date'));
     $this->validatorSchema['activity_date_from'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema['activity_date_to'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound), array('invalid' => 'Date provided is not valid'));
     $people_types = array('' => '');
     $types = People::getTypes();
     foreach ($types as $flag => $name) {
         $people_types[strval($flag)] = $name;
     }
     $this->widgetSchema['people_type'] = new sfWidgetFormChoice(array('choices' => $people_types));
     $this->widgetSchema['people_type']->setLabel('Role');
     $this->validatorSchema['people_type'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys($people_types)));
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('activity_date_from', '<=', 'activity_date_to', array('throw_global_error' => true), array('invalid' => 'The to date cannot be above the "end" date.')));
 }
Пример #2
0
 public function executeView(sfWebRequest $request)
 {
     $this->people = Doctrine::getTable('People')->find($request->getParameter('id'));
     $this->forward404Unless($this->people, 'People not Found');
     $this->form = new PeopleForm($this->people);
     $this->types = People::getTypes();
     $this->loadWidgets();
 }
Пример #3
0
<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(20, new lime_output_color());
$p = new People();
$p->setFormatedName('Mr Poilux Duchesne');
$t->info('Test "__toString" method to get formated name of given person');
$t->is($p->__toString(), 'Mr Poilux Duchesne', 'to string get "FormatedName": "Mr Poilux Duchesne"');
$t->info('Get static list of people types');
$types = People::getTypes();
$t->is($types['identifier'], 'Identifier', 'We have "Identifier" as Type');
$t->is($types['collector'], 'Collector', 'We have "Collector" as Type');
$t->info('DB people types tests');
$p->setBirthDate('05/12/1908');
$t->is($p->getBirthDate(), array('year' => '', 'month' => '', 'day' => '', 'hour' => '', 'minute' => '', 'second' => ''), 'We have set a null birth date');
$p->setBirthDate(new FuzzyDateTime('1975/02/24 13:12:11', 48));
$t->is($p->getBirthDate(), array('year' => '1975', 'month' => '02', 'day' => '', 'hour' => '', 'minute' => '', 'second' => ''), 'We have set a birth date');
$t->is($p->getBirthDateObject()->format('y/M'), '75/Feb', 'We get a birth date object');
$t->is($p->getBirthDateMasked(), '<em>24</em>/02/1975', 'We get a birth date masked');
$p->setBirthDate('1900/05/2');
$t->is($p->getBirthDate(), array('year' => '1900', 'month' => '05', 'day' => '', 'hour' => '', 'minute' => '', 'second' => ''), 'We have set a End date');
$p->setEndDate(new FuzzyDateTime('1975/03/24 13:12:11', 48));
$t->is($p->getEndDate(), array('year' => '1975', 'month' => '03', 'day' => '', 'hour' => '', 'minute' => '', 'second' => ''), 'We have set a End date');
$t->is($p->getEndDateObject()->format('y/M'), '75/Mar', 'We get a End date object');
$t->is($p->getEndDateMasked(), '<em>24</em>/03/1975', 'We get a End date masked');
$p->setEndDate('1975/05/2');
$t->is($p->getEndDate(), array('year' => '1975', 'month' => '05', 'day' => '', 'hour' => '', 'minute' => '', 'second' => ''), 'We have set a End date');
$p->setActivityDateFrom(new FuzzyDateTime('1975/04/24 13:12:11', 48));
$t->is($p->getActivityDateFrom(), array('year' => '1975', 'month' => '04', 'day' => '', 'hour' => '', 'minute' => '', 'second' => ''), 'We have set a activity from date');
$t->is($p->getActivityDateFromObject()->format('y/M'), '75/Apr', 'We get a activity from date object');
$t->is($p->getActivityDateFromMasked(), '<em>24</em>/04/1975', 'We get a activity from date masked');