예제 #1
0
 public function run()
 {
     if ($this->showPlaceholder) {
         $this->htmlOptions['placeholder'] = strtr($this->mask, '9a*', '___');
     }
     parent::run();
 }
예제 #2
0
 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();
 }
 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;
 }
예제 #4
0
 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();
 }