mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Fixes #1042 - remove fillable constraint on models when saving
Form fields are already constrained by their fields.yaml definition (values not defined in the yaml will not be saved) so we don't need to double dip by enforcing fillable too.
This commit is contained in:
parent
f12101671e
commit
af657e9399
@ -912,15 +912,13 @@ class RelationController extends ControllerBehavior
|
||||
$sessionKey = $this->deferredBinding ? $this->relationGetSessionKey(true) : null;
|
||||
|
||||
if ($this->viewMode == 'multi') {
|
||||
|
||||
if ($this->relationType == 'hasMany') {
|
||||
$newModel = $this->relationObject->create($saveData, $sessionKey);
|
||||
}
|
||||
elseif ($this->relationType == 'belongsToMany') {
|
||||
$newModel = $this->relationObject->create($saveData, [], $sessionKey);
|
||||
$newModel = $this->relationModel;
|
||||
$modelsToSave = $this->prepareModelsToSave($newModel, $saveData);
|
||||
foreach ($modelsToSave as $modelToSave) {
|
||||
$modelToSave->save(null, $this->manageWidget->getSessionKey());
|
||||
}
|
||||
|
||||
$newModel->commitDeferred($this->manageWidget->getSessionKey());
|
||||
$this->relationObject->add($newModel, $sessionKey);
|
||||
}
|
||||
elseif ($this->viewMode == 'single') {
|
||||
$newModel = $this->viewModel;
|
||||
@ -961,8 +959,10 @@ class RelationController extends ControllerBehavior
|
||||
|
||||
if ($this->viewMode == 'multi') {
|
||||
$model = $this->relationModel->find($this->manageId);
|
||||
$model->fill($saveData);
|
||||
$model->save(null, $this->manageWidget->getSessionKey());
|
||||
$modelsToSave = $this->prepareModelsToSave($model, $saveData);
|
||||
foreach ($modelsToSave as $modelToSave) {
|
||||
$modelToSave->save(null, $this->manageWidget->getSessionKey());
|
||||
}
|
||||
}
|
||||
elseif ($this->viewMode == 'single') {
|
||||
$this->viewWidget->setFormValues($saveData);
|
||||
|
@ -291,7 +291,7 @@ class Form extends WidgetBase
|
||||
$data = $this->getSaveData();
|
||||
}
|
||||
|
||||
$this->model->fill($data);
|
||||
$this->model->forceFill($data);
|
||||
$this->data = (object) array_merge((array) $this->data, (array) $data);
|
||||
|
||||
foreach ($this->allFields as $field) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user