root/trunk/lib/form/CountrySelectorForm.class.php

Revision 68, 1.2 kB (checked in by nperriault, 2 years ago)

[1.1] everything is broken \o/

Line 
1 <?php
2 /**
3  * Country selection class
4  *
5  * @package    symfonians
6  * @subpackage forms
7  */
8 class CountrySelectorForm extends sfForm
9 {
10   protected
11     $countries = array(),
12     $culture   = 'en';
13  
14   /**
15    * Public constructor
16    *
17    * @param  array  $countries  An optional list of country codes
18    * @see    sfForm
19    */
20   public function __construct($countries = array(), $defaults = array(), $options = array(), $CSRFSecret = null)
21   {
22     $this->countries = array_keys($countries);
23     $this->culture = sfContext::getInstance()->getUser()->getCulture();
24     parent::__construct($defaults, $options, $CSRFSecret);
25   }
26  
27   /**
28    * Form configuration
29    *
30    */
31   public function configure()
32   {
33     $this->setWidgets(array(
34       'country' => new sfWidgetFormI18nSelectCountry(array('culture' => $this->culture,
35                                                            'countries' => $this->countries,
36                                                            'include_custom' => array('' => __('Any country')))),
37     ));
38     
39     $this->setValidators(array(
40       'country' => new sfValidatorI18nChoiceCountry(array('culture' => $this->culture,
41                                                           'countries' => $this->countries)),
42     ));
43   }
44 }
45
Note: See TracBrowser for help on using the browser.