Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
It seems that there are several places where we have $v = &$form_state->getValue(…);
but also many use $v = $form_state->getValue(…);
Proposed resolution
We need to determine which is correct and make it consistent.
Remaining tasks
TBD
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
getvalue_references.png | 243.63 KB | thpoul |
Comments
Comment #2
Wim LeersI think this is highly confusing.
Comment #3
tim.plunkett"We need to determine which is correct and make it consistent."
They do different things?
I have no idea how to address this.
Comment #4
tim.plunkettAre you saying we should ban any use of & in assignment?
Before:
After:
Comment #5
dawehnerThis issue feels just pointless to me. These instances choose references in order to manipulate the value in there, for which its a valid way to use references. For most cases though you don't want to manipulate the values and so as such, the reference symbol is not needed.
PHP has language features, I believe strongly that we should leverage them also in a semantic way.
Comment #6
tim.plunkettAgreed.
Comment #7
tim.plunkettOkay instead let's make sure all instances are actually needed
Comment #11
yash_khandelwalHello,
I am having a problem with port below code to Drupal 8.
$form_state['field_deltas'][] = count($form_state['field_deltas']) > 0 ?max($form_state['field_deltas']) +1: 0;
Also how to fetch data in drupal 8 like below (Drupal 7).
$delta_remove = $form_state['triggering_element']['#parents'][1];
Does anyone have the solution for this issue?