Skip to content

Commit

Permalink
Update Fields.php
Browse files Browse the repository at this point in the history
In save, check that values are hidden. If so, clean the database if previously recorded, or do not save anything
  • Loading branch information
obuisard committed Sep 9, 2023
1 parent aa52c06 commit f1929d5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/system/fields/src/Extension/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ public function onContentAfterSave($context, $item, $isNew, $data = []): void

// Loop over the fields
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)) {
// Remove value from database
$model->setFieldValue($field->id, $item->id, null);
continue;
}

// Determine the value if it is (un)available from the data
if (array_key_exists($field->name, $data['com_fields'])) {
$value = $data['com_fields'][$field->name] === false ? null : $data['com_fields'][$field->name];
Expand Down

0 comments on commit f1929d5

Please sign in to comment.