fieldMap = $this->getConfig('fieldMap', []); $this->countryRestriction = $this->getConfig('countryRestriction', ''); } /** * {@inheritDoc} */ public function render() { $this->prepareVars(); return $this->makePartial('addressfinder'); } /** * prepareVars for the list data */ public function prepareVars() { $this->vars['name'] = $this->formField->getName(); $this->vars['value'] = $this->getLoadValue(); $this->vars['field'] = $this->formField; } /** * getFieldMapAttributes */ public function getFieldMapAttributes() { $fields = $this->getParentForm()->getFields(); $result = []; foreach ($this->fieldMap as $map => $fieldName) { if (!$field = array_get($fields, $fieldName)) { continue; } $result['data-input-'.$map] = '#'.$field->getId(); } return Html::attributes($result); } /** * getCountryRestriction */ public function getCountryRestriction() { return $this->countryRestriction; } /** * {@inheritDoc} */ public function loadAssets() { $apiKey = Setting::get('google_maps_key'); $this->addJs('//maps.googleapis.com/maps/api/js?libraries=places&key='.$apiKey); $this->addJs('js/location-autocomplete.js', 'core'); } }