1 <?php
2 3 4 5 6 7 8 9 10 11
12 Yii::import('yiiwheels.widgets.formhelpers.WhDropDownInputWidget');
13
14 class WhStates extends WhDropDownInputWidget
15 {
16 17 18 19
20 public $country;
21
22 public function init()
23 {
24 if (empty($this->country)) {
25 throw new CException('"$country" cannot be empty.');
26 }
27 $this->pluginOptions['country'] = $this->country;
28
29 parent::init();
30
31 TbHtml::addCssClass('bfh-states', $this->htmlOptions);
32
33 if(!isset($this->htmlOptions['data-state'])) {
34 $this->htmlOptions['data-state'] = TbArray::popValue('data-value', $this->htmlOptions);
35 }
36 unset($this->htmlOptions['data-name'], $this->htmlOptions['data-value']);
37 }
38
39 public function run()
40 {
41 if(!$this->readOnly) {
42 echo $this->dropDownList();
43 } else
44 {
45 echo CHtml::tag('span', $this->htmlOptions, '');
46 }
47
48 $this->registerPlugin('bfhstates');
49 }
50 }