public function setup()
 {
     parent::setup();
     unset($this['created_at'], $this['updated_at']);
     // checking that some polls are available
     if (false === aPollToolkit::getAvailablePolls(false)) {
         throw new sfException('Cannot find any poll item in apoll_settings_available_polls. Please, define some in app.yml');
     }
     $available_polls = aPollToolkit::getAvailablePolls();
     $choices = array();
     $choices_keys = array();
     foreach ($available_polls as $key => $poll) {
         $choices[$key] = isset($poll['name']) ? $poll['name'] : $key;
         $choices_keys[] = $key;
     }
     $this->widgetSchema['type'] = new sfWidgetFormChoice(array('choices' => $choices));
     $this->validatorSchema['type'] = new sfValidatorAnd(array(new sfValidatorChoice(array('choices' => $choices_keys, 'required' => true)), new aPollValidatorPollItem(array('poll_items' => aPollToolkit::getAvailablePolls()))), array('halt_on_error' => true));
     $culture = sfContext::getInstance()->getUser()->getCulture();
     $date_options = array('image' => '/apostrophePlugin/images/a-icon-datepicker.png', 'culture' => $culture, 'config' => '{changeMonth: true,changeYear: true}');
     $time_attributes = array('twenty-four-hour' => true, 'minutes-increment' => 30);
     $this->setWidget('published_from', new aWidgetFormJQueryDateTime(array('date' => $date_options), array('time' => $time_attributes)));
     $this->setWidget('published_to', new aWidgetFormJQueryDateTime(array('date' => $date_options), array('time' => $time_attributes)));
     $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'validateEndDate'))));
     $this->setWidget('submissions_allow_multiple', new aWidgetFormChoice(array('choices' => array(true => 'Yes', false => 'No'))));
     $this->setWidget('submissions_delay', new sfWidgetFormTime(array('hours' => self::generateTwoCharsRange(0, 120)), $time_attributes));
     // setting translation catalogue
     $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe');
     // embedding i18n fields
     $culture = sfContext::getInstance()->getUser()->getCulture();
     $languages = sfCultureInfo::getInstance($culture)->getLanguages(sfConfig::get('app_a_i18n_languages'));
     $this->embedI18n(array_keys($languages));
     foreach ($languages as $key => $value) {
         $this->widgetSchema->setLabel($key, ucfirst($value));
     }
 }
 public function configure()
 {
     $this->setWidgets(array('poll' => new sfWidgetFormInputText()));
     $available_polls = aPollToolkit::getAvailablePolls();
     $this->setValidators(array('poll' => new sfValidatorAnd(array(new sfValidatorChoice(array('choices' => array_keys($available_polls), 'required' => true)), new aPollValidatorPollItem(array('poll_items' => $available_polls))), array('halt_on_error' => true))));
     // Ensures unique IDs throughout the page. Hyphen between slot and form to please our CSS
     $this->widgetSchema->setNameFormat('a-poll-form-view[%s]');
     // You don't have to use our form formatter, but it makes things nice
     $this->widgetSchema->setFormFormatterName('aAdmin');
     // setting translation catalogue
     $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe');
     $this->disableCSRFProtection();
 }
 public function setup()
 {
     parent::setup();
     // checking that some polls are available
     if (false === aPollToolkit::getAvailablePolls(false)) {
         throw new sfException('Cannot find any poll item in apoll_settings_available_polls. Please, define some in app.yml');
     }
     $available_polls = aPollToolkit::getAvailablePolls();
     $choiches = array();
     foreach ($available_polls as $key => $poll) {
         $choiches[$key] = isset($poll['name']) ? $poll['name'] : $key;
     }
     $this->widgetSchema['type'] = new sfWidgetFormChoice(array('choices' => $choiches, 'multiple' => true, 'expanded' => true));
     $culture = sfContext::getInstance()->getUser()->getCulture();
     $date_options = array('image' => '/apostrophePlugin/images/a-icon-datepicker.png', 'culture' => $culture, 'config' => '{changeMonth: true,changeYear: true}');
     $this->setWidget('published_from', new sfWidgetFormFilterDate(array('from_date' => new aWidgetFormJQueryDate($date_options), 'to_date' => new aWidgetFormJQueryDate($date_options))));
     $this->setWidget('published_to', new sfWidgetFormFilterDate(array('from_date' => new aWidgetFormJQueryDate($date_options), 'to_date' => new aWidgetFormJQueryDate($date_options))));
     // setting translation catalogue
     $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe');
 }