Consistently make all form callbacks take $element by reference

Created on 28 April 2012, about 13 years ago
Updated 26 June 2023, almost 2 years 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 1 day 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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Currently going through the end of the queue to see what could still be relevant for D10.

    Wondering if this is still a valid task?

  • Status changed to Closed: outdated 12 days ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    There has been no work on this task for 13 years. It is likely that it is no longer needed or has been implemented. Therefor, closing.

    If there is work to do here, then either re-open the issue and add a comment or open a new issue and reference this one.

Production build 0.71.5 2024