How to remove the telephone number using IntlPhoneInput plugin

  javascript, php, yii1.x

I tired to remove the telephone number in javascript file <span class="dial-code">+60</span> but the telephone number still appear on the dropdownlist.
Country Flag with telephone number
Even I tried to delete the file which is css and js, it still can show the country flag with telephone number. I do not know why still can load the dropdownlist with country flag and telephone number. Any method that can remove the telephone number? I only want show the country flag in dropdownlist.

intlphoneinput.php

<?php

class IntlPhoneInput extends CInputWidget
{

        public $options;

        public $localisedCountryNames=true;

        public $E164=true;

        private $utilsScript;


        public function run()
        {
                list($name, $id)=$this->resolveNameID();
                if(!isset($this->htmlOptions['id']))
                        $this->htmlOptions['id']=$id;
                if(!isset($this->htmlOptions['name']))
                        $this->htmlOptions['name']=$name;

                $this->registerClientScript();

                if($this->hasModel()) {
                        $value=$this->model->{$this->attribute};
                        echo CHtml::activeHiddenField($this->model, $this->attribute);
                }
                else {
                        $value=$this->value;
                        echo CHtml::hiddenField($this->htmlOptions['name'], $this->value);
                }
                $htmlOptions=$this->htmlOptions;
                unset($htmlOptions['id'], $htmlOptions['name']);
                echo CHtml::hiddenField('intl-phone-input', $value, $htmlOptions);
        }


        private function registerClientScript()
        {
                $assets=Yii::app()->getAssetManager()->publish(dirname(__FILE__) . '/build');
                $lib=Yii::app()->getAssetManager()->publish(dirname(__FILE__) . '/lib');
                $this->utilsScript=$lib . '/libphonenumber/build/utils.js';

                // Configures JavaScript
                $config=$this->config();
                $options=CJavaScript::encode($config);
                $js="jQuery('#intl-phone-input').intlTelInput({$options});";

                $clone='val()';
                if($this->E164 === true)
                        $clone='intlTelInput('getNumber')';
                $js.="jQuery('#intl-phone-input').change(function() {
                        jQuery('#{$this->htmlOptions['id']}').val(jQuery(this).{$clone});
                });";

                if($this->localisedCountryNames === true) {
                        $js.="var countryData = $.fn.intlTelInput.getCountryData();
                        $.each(countryData, function(i, country) {
                                country.name = country.name.replace(/.+((.+))/,'$1');
                        });";
                }

                // Add other JavaScript methods to $js.
                // See https://github.com/Bluefieldscom/intl-tel-input#public-methods
                // See https://github.com/Bluefieldscom/intl-tel-input#static-methods

                $cs=Yii::app()->getClientScript();
                $cs->registerCssFile($assets . '/css/intlTelInput.css');
                $cs->registerScriptFile($assets . '/js/intlTelInput.min.js');
                $cs->registerScript(__CLASS__ . '#' . $this->htmlOptions['id'], $js);
        }


        private function config()
        {
                // Predefined settings.
                $options=array(
                        'onlyCountries' => ['sg', 'my', 'other'],
                        'responsiveDropdown' => true,
                        'nationalMode' => false,
                        'autoHideDialCode' => true,
                );
                // Client options
                if(is_array($this->options)) {
                        foreach($this->options as $key => $value)
                                $options[$key]=$value;
                }
                // Specifies/overwrites the path to the included "utils.js" script
                $options['utilsScript']=$this->utilsScript;
                return $options;
        }

}

intlphoneinput.js

        _appendListItems: function(countries, className) {
            // we create so many DOM elements, I decided it was faster to build a temp string
            // and then add everything to the DOM in one go at the end
            var tmp = "";
            // for each country
            for (var i = 0; i < countries.length; i++) {
                var c = countries[i];
                // open the list item
                tmp += "<li class='country " + className + "' data-dial-code='" + c.dialCode + "' data-country-code='" + c.iso2 + "'>";
                // add the flag
                tmp += "<div class='flag " + c.iso2 + "'></div>";
                // and the country name and dial code
                tmp += "<span class='country-name'>" + c.name + "</span>";
                tmp += "<span class='dial-code'>+" + c.dialCode + "</span>";
                // close the list item
                tmp += "</li>";
            }
            this.countryList.append(tmp);
        },

Source: Ask PHP

LEAVE A COMMENT