Consistently make all form callbacks take $element by reference

Created on 28 April 2012, about 12 years ago
Updated 26 June 2023, about 1 year ago

Problem

  • Some form callbacks return a copy of $element, some others alter &$element by reference.

Goal

  • Consistently pass $element to Form API callbacks.

Proposed solution

  1. Change all Form API callbacks to take $element by reference:

    D7:

    function form_process_radios($element) {
      ...
        $element['foo'] = 'bar';
      ...
      return $element;
    }
    

    D8:

    function form_process_radios(&$element) {
      ...
        $element['foo'] = 'bar';
      ...
    }
    

Notes

  • If form elements will ever be objects, they will behave as if they were passed by reference, too. So this is a compatible step into that direction.
  • Render API should ideally be changed to follow this consistency, since Form API elements usually interact deeply with Render API.
πŸ“Œ Task
Status

Postponed: needs info

Version

9.5

Component
FormΒ  β†’

Last updated about 7 hours ago

Created by

πŸ‡©πŸ‡ͺGermany sun Karlsruhe

Live updates comments and jobs are added and updated live.
  • API change

    Changes an existing API or subsystem. Not backportable to earlier major versions, unless absolutely required to fix a critical bug.

  • API clean-up

    Refactors an existing API or subsystem for consistency, performance, modularization, flexibility, third-party integration, etc. May imply an API change. Frequently used during the Code Slush phase of the release cycle.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024