5 class Phone extends \Rsi\Fred\Controller\View\Html\Widget\Char{
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'],[
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'
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);