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.
Beta phase evaluation
Reduces API Fragility | The temporary form storage area has no api, and currently must be interacted with in old-style array-pi. This can lead to misunderstanding of use and even in appropriate usage circumstances can include generating quite a few lines of codes for what a single method could do. In short, mirroring the methods we have for non-temporary sections of the form-state will keep the API consistent and usable. |
---|---|
Disruption | Not disruptive for core/contributed modules because it will only introduce a new API which is only used once in core and will streamline contribs use of this feature. |
Problem/Motivation
#2339151: Conditions / context system does not allow for multiple configurable contexts, eg. language types (a major bug) starts to use FAPI's temporary storage, but it has proven cumbersome compared to regular storage.
$temporary = $form_state->getTemporary();
$temporary['foo'] = 'bar';
$form_state->setTemporary();
As opposed to:
$form_state->setTemporaryValue('foo', 'bar');
Proposed resolution
Add getTemporaryValue, setTemporaryValue, and hasTemporaryValue.
Remaining tasks
N/A
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#13 | interdiff.txt | 429 bytes | tim.plunkett |
#13 | form-state-temp-2371853-13.patch | 6.08 KB | tim.plunkett |
Comments
Comment #1
tim.plunkettComment #2
larowlanI think we need some tests for this? Tackling
Comment #3
larowlanAdds tests
I consider this ready.
Comment #4
andypostPlease change this to 2 data vars with some random names allowed
Comment #5
EclipseGc CreditAttribution: EclipseGc commentedWhat a great change! Not to run over andy here, but that seems very nitpicky for something we can use now. RTBCing unless people really feel strongly about this.
Eclipse
Comment #6
alexpottThis issue is a normal task so we need to outline how it fits within the allowable Drupal 8 beta criteria. Can someone add Drupal 8 beta phase evaluation template to the issue summary.
Also #2339151: Conditions / context system does not allow for multiple configurable contexts, eg. language types has landed so I guess we should be able to make use of these additions in Core.
Comment #7
EclipseGc CreditAttribution: EclipseGc commentedComment #8
EclipseGc CreditAttribution: EclipseGc commentedComment #9
EclipseGc CreditAttribution: EclipseGc commentedUpdated the IS
Eclipse
Comment #10
alexpottWhat about
Comment #11
tim.plunkettAddressing the other half of #6
Comment #13
tim.plunkettHah! Glad we tried to use this.
Comment #14
alexpottThis normal task reduces fragility by adding a better API so is allowed as per https://www.drupal.org/core/beta-changes and it's benefits outweigh any disruption. Committed 9bb4f4c and pushed to 8.0.x. Thanks!
So let's make the test cover what @tim.plunkett found in #13 too. Fixed on commit.