Skip to content

Commit

Permalink
Update Fields.php
Browse files Browse the repository at this point in the history
Added onCustomFieldsBeforeSave to onContentAfterSave
  • Loading branch information
obuisard committed Sep 11, 2023
1 parent 05a331f commit e105c62
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugins/system/fields/src/Extension/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function onContentAfterSave($context, $item, $isNew, $data = []): void
foreach ($fields as $field) {
// Empty fields that are hidden so that their values will be removed if they exist
$showOn = $field->params->get('showon', '');
if (!empty($showOn) && FieldsHelper::matchShowon($showOn, $fields)) {
if (!empty($showOn) && !FieldsHelper::matchShowon($showOn, $fields)) {
// Remove value from database
$model->setFieldValue($field->id, $item->id, null);
continue;
Expand All @@ -163,8 +163,11 @@ public function onContentAfterSave($context, $item, $isNew, $data = []): void
$value = json_encode($value);
}

$field->rawvalue = $value;
Factory::getApplication()->triggerEvent('onCustomFieldsBeforeSave', [&$field]);

// Setting the value for the field and the item
$model->setFieldValue($field->id, $item->id, $value);
$model->setFieldValue($field->id, $item->id, $field->rawvalue);
}
}

Expand Down

0 comments on commit e105c62

Please sign in to comment.