diff --git a/modules/cms/models/ThemeData.php b/modules/cms/models/ThemeData.php index 907887d7e8..b6ff9af8b4 100644 --- a/modules/cms/models/ThemeData.php +++ b/modules/cms/models/ThemeData.php @@ -52,6 +52,14 @@ class ThemeData extends Model */ protected static $instances = []; + /** + * after the model is booted, bind to 'model.afterFetch' event + */ + public function afterBoot() + { + $this->bindEvent('model.afterFetch', [$this, 'afterFetchHandler']); + } + /** * Before saving the model, strip dynamic attributes applied from config. * @return void @@ -109,18 +117,18 @@ public static function forTheme($theme) * on form field definitions. * @return void */ - public function afterFetch() + protected function afterFetchHandler() { $data = (array) $this->data + $this->getDefaultValues(); - /* - * Repeater form fields store arrays and must be jsonable. - */ foreach ($this->getFormFields() as $id => $field) { if (!isset($field['type'])) { continue; } + /* + * Repeater form fields store arrays and must be jsonable. + */ if ($field['type'] === 'repeater') { $this->jsonable[] = $id; }