Exemplo n.º 1
1
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $this->hidden ? $id . '_hidden' : $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     } else {
         $this->htmlOptions['name'] = $this->hidden ? $name . '_hidden' : $name;
     }
     if ($this->hasModel()) {
         echo $this->hidden ? BsHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions) : BsHtml::activeTelFieldControlGroup($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo $this->hidden ? CHtml::hiddenField($name, $this->value, $this->htmlOptions) : CHtml::textField($name, $this->value, $this->htmlOptions);
     }
     $options = CJavaScript::encode($this->options);
     $js = "jQuery('#{$id}').{$this->mode}picker({$options});";
     if (isset($this->language)) {
         $this->registerScriptFile($this->i18nScriptFile);
         $js = "jQuery('#{$id}').{$this->mode}picker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));";
     }
     $cs = Yii::app()->getClientScript();
     $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets');
     $cs->registerCssFile($assets . self::ASSETS_NAME . '.css');
     $cs->registerScriptFile($assets . self::ASSETS_NAME . '.js', CClientScript::POS_END);
     $cs->registerScript(__CLASS__, $this->defaultOptions ? 'jQuery.{$this->mode}picker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : '');
     $cs->registerScript(__CLASS__ . '#' . $id, $js);
 }
Exemplo n.º 2
0
 /**
  * Generates a control group with an telephone field for a model attribute.
  * @param CModel $model the data model.
  * @param string $attribute the attribute name.
  * @param array $htmlOptions additional HTML attributes.
  * @return string the generated row.
  * @see BsHtml::activeTelFieldControlGroup
  */
 public function telFieldControlGroup($model, $attribute, $htmlOptions = array())
 {
     $htmlOptions = $this->processRowOptions($model, $attribute, $htmlOptions);
     return BsHtml::activeTelFieldControlGroup($model, $attribute, $htmlOptions);
 }