コード例 #1
0
 private function getWidgetScript($callback)
 {
     Yii::app()->clientScript->scripts = array();
     ob_start();
     $widget = new CMaskedTextField(null);
     $widget->name = 'test';
     $widget->completed = $callback;
     $widget->mask = '99/99/9999';
     $widget->init();
     $widget->run();
     Yii::app()->clientScript->render($out);
     ob_end_clean();
     return $out;
 }
コード例 #2
0
 public function run()
 {
     if ($this->showPlaceholder) {
         $this->htmlOptions['placeholder'] = strtr($this->mask, '9a*', '___');
     }
     parent::run();
 }
コード例 #3
0
ファイル: Phone.php プロジェクト: igorsantos07/yii-br-pack
 public function run()
 {
     if (!$this->type) {
         throw new \CException(\Yii::t('yii', 'Property PhoneField.type cannot be empty.'));
     }
     switch ($this->type) {
         case 'area':
             $this->mask = '99';
             $this->placeholder = ' ';
             break;
         case 'landline':
             $this->mask = '(99) 9999-9999';
             $this->placeholder = '_';
             break;
         case 'both':
         case 'mobile':
             $this->mask = '(99) 9999-9999?9';
             $this->placeholder = '_';
             break;
         default:
             throw new \CException(\Yii::t('yii', 'Property PhoneField.type should be one of "landline", "mobile", "both" or "area".'));
     }
     if ($this->showPlaceholder) {
         $this->htmlOptions['placeholder'] = str_replace([9, '?'], [$this->placeholder, ''], $this->mask);
     }
     parent::run();
 }
コード例 #4
0
ファイル: Card.php プロジェクト: igorsantos07/yii-br-pack
 public function run()
 {
     $this->guessType();
     switch ($this->type) {
         case 'cvv':
             $this->mask = '999';
             $this->placeholder = ' ';
             break;
         case 'expiry':
             $this->mask = '99/99';
             $this->placeholder = '_';
             break;
         case 'pan':
             $this->mask = '9999 9999 9999 9999';
             $this->placeholder = ' ';
             break;
         default:
             throw new \CException(Yii::t('yii', 'Could not guess CardField type nor CardField.type is defined.'));
     }
     if ($this->showPlaceholder) {
         $this->htmlOptions['placeholder'] = str_replace(9, $this->placeholder, $this->mask);
     }
     parent::run();
 }
コード例 #5
0
 public function init()
 {
     $this->mask = $this->masks[$this->type];
     parent::init();
 }