Geo > Metro * @copyright Tamaranga */ class Metro extends MetroStationSelect { public function init() { parent::init(); $this->stationId = function () { return $this->form->item['metro_id'] ?? 0; }; $this->cityId = function () { return $this->form->item['geo_city'] ?? 0; }; $this->prerenderable(true); $this->addWrapper('form/blocks/metro', 'listings'); } public function visible() { $geo = $this->form->category['settings']['geo'] ?? []; if (($geo['enabled'] ?? false) && ($geo['metro'] ?? 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 validate($data = []) { $data = parent::validate($data); if (! $this->visible()) { unset($data['metro_id']); } return $data; } }