Skip to content

Commit

Permalink
improve code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin committed Feb 22, 2024
1 parent 36353b0 commit 0bed2fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ protected function extendCmsModule(): void
ThemeData::extend(function ($model) {
$model->bindEvent('model.afterFetch', function() use ($model) {
$translatable = [];
foreach ($model->getFormFields() as $id => $field) {
if (!empty($field['translatable'])) {
$translatable[] = $id;
foreach ($model->getFormFields() as $fieldName => $fieldConfig) {
if (array_get($fieldConfig, 'translatable', false)) {
$translatable[] = $fieldName;
}
if (@$field['type'] === 'repeater') {
foreach (array_get($field, 'form.fields') as $name => $config) {
if (array_get($config, 'translatable')) {
$translatable[] = sprintf("%s[%s]", $id, $name);
if (array_get($fieldConfig, 'type', 'text') === 'repeater') {
foreach (array_get($fieldConfig, 'form.fields', []) as $repeaterFieldName => $repeaterFieldConfig) {
if (array_get($repeaterFieldConfig, 'translatable', false)) {
$translatable[] = sprintf("%s[%s]", $fieldName, $repeaterFieldName);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion formwidgets/MLRepeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public function getSaveValue($value)
if ($this->translationMode === 'repeater') {
$this->rewritePostValues();
$value = $this->getLocaleSaveValue($value);
} elseif ($this->translationMode === 'fields') {
}
elseif ($this->translationMode === 'fields') {
$localeValues = $this->getLocaleSaveValue($value);
if ($value) {
foreach ($value as $index => &$_data) {
Expand Down

0 comments on commit 0bed2fc

Please sign in to comment.