Halycon models do not declare forceFill

Only bind purgeable fallback event once (only needed once)
Refs https://github.com/rainlab/translate-plugin/issues/54#issuecomment-256067096
This commit is contained in:
Samuel Georges 2016-11-05 10:59:53 +11:00
parent 7b0f33e9b3
commit 50d3ffb035
2 changed files with 5 additions and 2 deletions

View File

@ -90,7 +90,7 @@ trait FormModelSaver
$model->addPurgeable($attributesToPurge);
}
else {
$model->bindEvent('model.saveInternal', function() use ($model, $attributesToPurge) {
$model->bindEventOnce('model.saveInternal', function() use ($model, $attributesToPurge) {
foreach ($attributesToPurge as $attribute) {
unset($model->attributes[$attribute]);
}

View File

@ -319,7 +319,10 @@ class Form extends WidgetBase
$data = $this->getSaveData();
}
$this->model->forceFill($data);
if (method_exists($this->model, 'forceFill')) {
$this->model->forceFill($data);
}
$this->data = (object) array_merge((array) $this->data, (array) $data);
foreach ($this->allFields as $field) {