AI translate settings form does not save entity reference settings

Created on 8 October 2024, about 2 months ago

Problem/Motivation

Entity reference translation checkboxes are in a fieldset now:

<?php
   $form['reference_defaults'] = [
      '#type' => 'details',
      '#title' => $this->t('Entity reference translation'),
...
    $form['reference_defaults']['reference_defaults'] = [
      '#type' => 'checkboxes',
?>

submitForm() assumes that $form_state->getValue('reference_defaults') is an array of checkboxes value, while in fact it is an array ['reference_defaults' => <...real values>], so this code

<?php
    $config->set('reference_defaults', array_keys(array_filter($form_state->getValue('reference_defaults'))));
?>

always saves an empty array.

Steps to reproduce

  1. Visit /admin/config/ai/ai_translate
  2. Open Entity reference translation element
  3. Check at least one entity type
  4. Save

Expected: Checked entity type stays checked after save
Actual: No entity type is checked

Proposed resolution

Mark details element $form['reference_defaults'] as non-tree

Remaining tasks

Write the patch

🐛 Bug report
Status

Active

Version

1.0

Component

Other Submodules

Created by

🇧🇬Bulgaria valthebald Sofia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024