FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Phone.php
Go to the documentation of this file.
1 <?php
2 
4 
5 class Phone extends \Rsi\Fred\Controller\View\Html\Widget\Char{
6 
7  protected $_inputType = 'tel';
8 
9  protected function renderInput($value,$raw,$attribs = null){
10  $options = $this->html->option($this->_view->component('trans')->str($this->_widget->countrySelectCaption),['value' => '-']);
11  if(is_callable($popular = $this->_widget->popular)) $popular = call_user_func($this->_widget->popular);
12  $clean = $value ? preg_replace('/\\D+/','',$value) : null;
13  foreach($this->_widget->countries as $code => $country) $options .= $this->html->option($country['title'],[
14  'value' => $code,
15  'selected' => $selected = (count($this->_widget->countries) == 1) || ($value && preg_match('/^' . $country['callingCode'] . '(' . ($country['mask'] ?? '.+') . ')$/',$clean)),
16  'class' => $selected || !$popular || in_array($code,$popular) ? null : 'fred-unpopular'
17  ]);
18  if($this->_widget->popular) $options .= $this->html->option($this->_view->component('trans')->str($this->_widget->countryShowAllCaption),['value' => '+','class' => 'fred-show-all']);
19  return $this->html->select($options,$this->_widget->popular ? null : ['class' => 'fred-show-all']) . parent::renderInput($value,$raw,$attribs);
20  }
21 
22 }
Rsi\Fred\Controller\View\Html\Widget
Definition: Char.php:3
Rsi\Fred\Controller\View\Html\Widget\Phone
Definition: Phone.php:5
Rsi\Fred\Controller\View\Html\Widget\Phone\$_inputType
$_inputType
Definition: Phone.php:7
Rsi\Fred\Controller\View\Html\Widget\Phone\renderInput
renderInput($value, $raw, $attribs=null)
Definition: Phone.php:9