mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Merge pull request #440 from Flynsarmy/jsonableSettingsModels
Fix jsonable settingsmodel saving
This commit is contained in:
commit
a7fa3533fd
@ -55,6 +55,7 @@ class SettingsModel extends ModelBehavior
|
|||||||
$this->model->bindEvent('model.afterFetch', [$this, 'afterModelFetch']);
|
$this->model->bindEvent('model.afterFetch', [$this, 'afterModelFetch']);
|
||||||
$this->model->bindEvent('model.beforeSave', [$this, 'beforeModelSave']);
|
$this->model->bindEvent('model.beforeSave', [$this, 'beforeModelSave']);
|
||||||
$this->model->bindEvent('model.setAttribute', [$this, 'setModelAttribute']);
|
$this->model->bindEvent('model.setAttribute', [$this, 'setModelAttribute']);
|
||||||
|
$this->model->bindEvent('model.saveInternal', [$this, 'saveModelInternal']);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the config
|
* Parse the config
|
||||||
@ -139,15 +140,22 @@ class SettingsModel extends ModelBehavior
|
|||||||
$this->model->attributes = array_merge($this->fieldValues, $this->model->attributes);
|
$this->model->attributes = array_merge($this->fieldValues, $this->model->attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal save method for the model
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function saveModelInternal()
|
||||||
|
{
|
||||||
|
// Purge the field values from the attributes
|
||||||
|
$this->model->attributes = array_diff_key($this->model->attributes, $this->fieldValues);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Before the model is saved, ensure the record code is set
|
* Before the model is saved, ensure the record code is set
|
||||||
* and the jsonable field values
|
* and the jsonable field values
|
||||||
*/
|
*/
|
||||||
public function beforeModelSave()
|
public function beforeModelSave()
|
||||||
{
|
{
|
||||||
// Purge the field values from the attributes
|
|
||||||
$this->model->attributes = array_diff_key($this->model->attributes, $this->fieldValues);
|
|
||||||
|
|
||||||
$this->model->item = $this->recordCode;
|
$this->model->item = $this->recordCode;
|
||||||
if ($this->fieldValues)
|
if ($this->fieldValues)
|
||||||
$this->model->value = $this->fieldValues;
|
$this->model->value = $this->fieldValues;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user