Skip to content
Snippets Groups Projects

Issue #3491304: Clone field does not work

2 unresolved threads

Closes #3491304

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
93 93 $default_value = array_merge($default_value, $element['#default_value']);
94 94 }
95 95
96 $values += $default_value;
96 $values = isset($values) && is_array($values) ? $values : [];
97 $values = array_merge($values, $default_value);
  • Comment on lines -96 to +97

    $values += $default_value; gives an array that is different from the array returned from array_merge($values, $default_value);. It can be verified with the following code.

    $a1 = ["a" => 1, "b" => 2];
    $a2 = ["a" => 3, "c" => 4];
    $a1 = array_merge($a1, $a2);
    print_r($a1);
    
    $a1 = ["a" => 1, "b" => 2];
    $a2 = ["a" => 3, "c" => 4];
    $a1 += $a2;
    print_r($a1);
  • Please register or sign in to reply
  • Alberto Paderno requested changes

    requested changes

  • 93 93 $default_value = array_merge($default_value, $element['#default_value']);
    94 94 }
    95 95
    96 $values += $default_value;
    96 $values = isset($values) && is_array($values) ? $values : [];
    97 $values = array_merge($values, $default_value);
    • Comment on lines +96 to +97

      Furthermore, the error reported in the issue is Unsupported operand types: string + array, which means $values is a string. The code used in this merge request would use an empty array instead of a string, which probably would cause issues later.

    • Please register or sign in to reply
    Please register or sign in to reply
    Loading