root/trunk/lib/form/application/ApplicationForm.class.php

Revision 57, 2.2 kB (checked in by nperriault, 2 years ago)

Application add form, styles - still work in progress

Line 
1 <?php
2 /**
3  * Application form.
4  *
5  * @package    form
6  * @subpackage application
7  * @version    SVN: $Id: sfPropelFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $
8  */
9 class ApplicationForm extends BaseApplicationForm
10 {
11   public function configure()
12   {
13     $context = sfContext::getInstance();
14     $culture = $context->getUser()->getCulture();
15     sfLoader::loadHelpers('I18n');
16     
17     // Unset unused widgets
18     unset($this['created_at'],
19           $this['updated_at'],
20           $this['slug'],
21           $this['is_featured']);
22     
23     // Overriding widgets
24     $this->widgetSchema['tags']               = new sfWidgetFormInput();
25     $this->widgetSchema['screenshot_path']    = new sfWidgetFormInputFile();
26     $this->widgetSchema['country']            = new sfWidgetFormI18nSelectCountry(array('culture' => $culture));
27     $this->widgetSchema['started_at']         = new sfWidgetFormI18nDate(array('culture' => $culture));
28     $this->widgetSchema['released_at']        = new sfWidgetFormI18nDate(array('culture' => $culture));
29     
30     // Overriding validators
31     $this->validatorSchema['tags']            = new sfValidatorRegex(array('pattern' => '/[0-9\w-_ ]/i', 'required' => false));
32     $this->validatorSchema['screenshot_path'] = new sfValidatorFile(array('max_size' => 512000, 'required' => false));
33     $this->validatorSchema['country']         = new sfValidatorI18nChoiceCountry(array('culture' => $culture, 'required' => false));
34     $this->validatorSchema['started_at']      = new sfValidatorDate(array('required' => false));
35     $this->validatorSchema['ended_at']        = new sfValidatorDate(array('required' => false));
36     
37     // Redefined validators
38     $this->validatorSchema['homepage'] = new sfValidatorUrl();
39     $this->validatorSchema['feed_url'] = new sfValidatorOr(array(
40       new sfValidatorUrl(),
41       new sfValidatorChoice(array('choices' => array('http://', ''))),
42     ), array('required' => false));
43     
44     // Defaults
45     $this->setDefaults(array('homepage'    => 'http://',
46                              'feed_url'    => 'http://',
47                              'released_at' => 'today', // thanks strtotime()
48                              'is_featured' => null));
49   }
50 }
51
Note: See TracBrowser for help on using the browser.