Geo > Map & Address * @copyright Tamaranga */ class MapAddr extends MapAddrInput { public function init() { parent::init(); $this->cityId = function () { return $this->form->item['geo_city'] ?? 0; }; $this->addr = function () { return $this->form->item['addr_addr'] ?? ''; }; $this->lat = function () { return $this->form->item['addr_lat'] ?? ''; }; $this->lon = function () { return $this->form->item['addr_lon'] ?? ''; }; $this->prerenderable(true); $this->addWrapper(function ($content, $data) { $data['content'] = $content; $data['attr'] = $this->attr; return $this->view->template( 'form/blocks/addr', $data, 'listings' ); }); } public function visible() { $geo = $this->form->category['settings']['geo'] ?? []; if (($geo['enabled'] ?? false) && ($geo['addr'] ?? false)) { return parent::visible(); } return false; } public function reloadBlock($event) { if (! in_array($event, ['categoryChange', 'cityChange', 'publisherChange'])) { return false; } if ($this->visible()) { return $this->render(); } return ''; } public function attrAddr() { parent::attrAddr(); return []; } public function validate($data = []) { $data = parent::validate($data); if (! empty($data['geo_city'])) { $this->cityId = $data['geo_city']; } if (! $this->visible()) { unset($data['addr_addr'], $data['addr_lat'], $data['addr_lon']); } return $data; } }