1 <?php
2 3 4 5 6 7 8 9 10 11
12 Yii::import('yiiwheels.widgets.formhelpers.WhInputWidget');
13
14 class WhPhone extends WhInputWidget
15 {
16 17 18
19 public $format = false;
20
21 public function init()
22 {
23 parent::init();
24 TbHtml::addCssClass('bfh-phone', $this->htmlOptions);
25
26 $this->htmlOptions['data-format'] = $this->format;
27
28 unset($this->htmlOptions['data-name'], $this->htmlOptions['data-value']);
29 }
30
31 public function run()
32 {
33 if (!$this->readOnly) {
34 echo $this->hasModel()
35 ? CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions)
36 : CHtml::textField($this->name, $this->value, $this->htmlOptions);
37 } else {
38 $this->htmlOptions['data-number'] = $this->hasModel()
39 ? $this->model->{$this->attribute}
40 : $this->value;
41 echo CHtml::tag('span', $this->htmlOptions, '');
42 }
43
44 $this->registerPlugin('bfhphone');
45 }
46 }