Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions modules/cms/models/ThemeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down