Reviewed & tested by the community
Project:
Drupal core
Version:
main
Component:
forms system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
9 Mar 2015 at 04:02 UTC
Updated:
29 Jul 2026 at 18:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jibranThis issue also came up in #2426781-9: Custom OptionWidget have no empty option label.1. Let's fix it in 8.0.x first and then backport it to D7. Nothing is broken here so I think it's not a bug it's a task. Also added beta evaluation and improved issue summary.
Comment #2
jibranIt's a simple search and replace so it's a novice task. We also need a draft change record for this change.
Comment #3
vbouchetComment #4
vbouchetPlease find a patch.
I defined a constant OPTIONS_EMPTY_OPTION_KEY and replaced '_none' everywhere in the options module.
- Should we replace it everywhere in the core ? (form.inc, Entity, Field, User)
- Does "need a draft change record" means create a new row here ?
Comment #5
vbouchetComment #6
rteijeiro commentedRenamed the constant to
OPTIONS_EMPTY_NONEin order to follow current naming from #2426781: Custom OptionWidget have no empty option labelComment #7
jibranHmmm, I think
OPTIONS_EMPTY_OPTIONwould be much better but it should be defined in OptionsWidgetBase just like existing constants.Comment #8
dawehnerWith the patch applied I still see multiple places where _none is used.
Given the first search result, doesn't that mean, this constant belongs into the FAPI?
Comment #9
vbouchetPlease find a patch defining the constant into OptionsWidgetBase and replacing _none everywhere in the code (not only in options module).
This is my first patch using POO so please review it carefully and give your input so I can fix it if it's not the appropriate way (I'm definitely not sure the way I access the variable is appropriate).
Comment #10
jibranThank you very much for the patch. There are still some _none left in
OptionsWidgetsTestand one in docs options.api.php.Comment #11
vbouchetYou are right. Let me update this patch.
Comment #12
vbouchetPlease find an updated patch with missing "_none" replacements.
Comment #13
disasm commentedI don't see any more missing '_none' matches. Replacing '_none' with a constant seems like a great idea to me. I'm going to mark this RTBC.
Comment #14
dawehnerI doubt that its a good idea to have FAPI depend on OptionsWidgetBase
Comment #15
dawehnerSo either a constant in form.inc or maybe a new class, which would also handle form_select_options() in the future, would be a better place.
Comment #16
jibranLet's move it to form.inc then.
Comment #17
vbouchetComment #18
vbouchetSorry, missing replacement. Working on it.
Comment #19
vbouchetComment #20
vbouchetComment #22
vbouchet(facepalm)
Comment #23
vbouchetComment #24
amateescu commentedHow about OPTIONS_EMPTY_CHOICE as a name for this constant? OPTIONS_EMPTY_OPTION sounds a bit weird :) Not saying that we *have* to rename it, just bringing it up as an option (hah!)
We need to remove the two extra spaces here.
Comment #25
vbouchet1. I initially think about OPTIONS_EMPTY_OPTION_KEY as it's only used as a key in a select-list/radio.
2. Find an updated patch to remove extra-space. (I'm not drinking coffee, maybe I should regarding the number of wrong patch posted this morning)
Comment #26
larowlanAre we certain we want to introduce another global constant that will limit our ability to do phpunit tests? Should it be called OPTIONS_EMPTY_NONE, that implies it is from options.module?
Comment #27
joelpittet@larowlan the constant seems like a good idea and a bit of progress to keep that value consistent so I'm +1 on it.
Lack of PHP unit testing could be a concern but wouldn't it be better to abstract that into a class with a static class constant to do it all in? If so maybe that can be a follow-up?
OPTIONS_EMPTY_KEYseems short and to the point maybe?OPTIONS_EMPTY_NONEis a bit strange because we are trying to equate empty to _none don't you think?I'm not adverse to just leaving it
OPTIONS_EMPTY_OPTIONeither.OPTIONS_EMPTY_OPTION_KEYis getting long but don't mind it either.Comment #28
amateescu commentedOPTIONS_EMPTY_CHOICEis another suggestion (from #24) :)Comment #29
tim.plunkettPlease don't put it in form.inc.
Ideally form_select_options() would have been moved to a static method by now, the constant should go with it.
Comment #30
joelpittet@amateescu whoops didn't see your suggestion, just looked at the last few comments.
@tim.plunkett can we do the ideal at the moment? Or do you have a suggestion that would not be ideal but maybe better than form.inc for this constant to live and move this issue a further?
Comment #31
tim.plunkettI spent zero time on figuring out good names, but this is what I had in mind.
Comment #32
jibranIMHO this seems like followup. We can't really backport #31 to D7.
Comment #33
tim.plunkett#25 can absolutely be backported. We're not adding a new global constant to form.inc in D8 only to move it in a follow-up.
Comment #34
jp.stacey commentedThis issue is still classed as:
But it's not completely clear from the comment thread what's still required: there's a patch on #25 and a patch on #33, and discussion after the two of them. As this patch is also tagged as "Novice" then it would be good to clarify the next steps so anyone can pick it up.
I propose that what's remaining is:
If this is correct, the issue summary should be updated with these tasks and we can proceed to "proper" review.
Comment #35
jp.stacey commentedComment #36
jp.stacey commented(Triaged as part of Sprint Weekend 2016.)
Comment #37
dawehnerComment #38
ccjjmartin commentedWrote a draft change record
Comment #39
ethomas08 commentedWorking on as part of global sprint
Comment #40
kostyashupenkoRe-rolled patch from https://www.drupal.org/node/2448545#comment-9771769
There was a lot of conflicts with:
CONFLICT (content): Merge conflict in core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
CONFLICT (content): Merge conflict in core/modules/options/src/Tests/OptionsWidgetsTest.php
CONFLICT (modify/delete): core/modules/entity_reference/src/Tests/EntityReferenceAdminTest.php deleted in 3caa7b355ec2630758044cb9bdb5d7ed8a202196 and modified in Applying patch from issue 2448545 comment 9771769. Version Applying patch from issue 2448545 comment 9771769 of core/modules/entity_reference/src/Tests/EntityReferenceAdminTest.php left in tree.
CONFLICT (content): Merge conflict in core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php
CONFLICT (content): Merge conflict in core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php
CONFLICT (content): Merge conflict in core/includes/form.inc
Made it like in previous patch
Comment #43
ethomas08 commentedComment #44
dawehnerThis reroll was not perfect, let's add the tag back.
Comment #45
vprocessor commentedComment #46
vprocessor commentedrerolled
Comment #47
vprocessor commentedComment #48
vprocessor commentedComment #50
rasikap commentedComment #52
mradcliffeThis probably needs a re-roll. Unassigning as no work done on it within a few months.
The needs issue summary update still needs to be done to reflect comments from #25.
Comment #53
hoebekewim commentedComment #54
hoebekewim commentedComment #55
mmrares commentedI'm working on this at DrupalCon.
Comment #56
hitesh-jain commentedComment #57
hitesh-jain commentedComment #58
manuel garcia commentedPatch #46 applies cleanly against 8.3.x
Comment #60
joelpittetUpdated title and issue summary to reflect the patch in it's current state.
Comment #61
joelpittetHere's another re-roll with some of the extras that got in there removed and I put
form_get_options()in the helper as well.I'm not sure on the naming, maybe that can be shorter for things considering they are in an Options helper the methods and constant don't need to repeat that, what do you think?
Comment #64
joelpittetComment #65
joelpittetThis would need a re-roll.
Comment #66
jofitzRe-rolled.
Comment #67
Skabbkladden commentedI'm reviewing this patch.
Comment #68
wizonesolutionsI'm mentoring @Skabbkladden on this issue.
Comment #69
Skabbkladden commentedThe patch looks OK. I could not find any remaining uses of '_none'.
Comment #70
joelpittetA quick fix, if there are anybody up for it, maybe @Skabbkladden, is to update the deprecation notices to 8.5?
@deprecated in Drupal 8.3.x...should be@deprecated in Drupal 8.5.x...Comment #71
dinesh18 commentedHere is an updated patch and interdiff as per comment mentioned in #70
Comment #72
joelpittetThank you @Dinesh18
Comment #73
larowlanwhoops :)
lots of >80 here
Good to see this moving though, blast from the past (I asked dasha to file it...back when we were building stuff with D7)
Comment #74
jofitzAddressed @larowlan's concerns from #73.
Comment #76
joelpittetDue to the time that has passed, this issue would be good to do a once over the code to ensure it's being used in all the places it can be.
Comment #77
benjifisherComment #78
pfrillingI found two instances of '_none' in:
- drupal/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceSettings.php
- drupal/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php
Attached is a rerolled patch and interdiff.
Comment #79
pfrillingSorry, I removed my interdiff as It was incorrect.
Comment #80
benjifisher@pfrilling:
I created an interdiff for you. For future reference: https://www.drupal.org/documentation/git/interdiff
We usually use "reroll" when updating a patch that no longer applies cleanly. I would say that you "updated" the patch from #74.
Comment #83
volegerJust reroll.
There was moved simpletest test into the javascriptfunctional test.
Comment #84
Christie Alcidor commentedReviewed the patch. Found no errors using simplytest.me.
Comment #85
larowlanThis looks good, but we're not doing the deprecation as per the policy
This needs to be 8.8.x now
we need a trigger_error here for the deprecation and a deprecation test
same here, need to update the version, add a trigger_error and add a deprecation test
We also missed a few spots:
Comment #87
akashkumar07 commentedComment #88
jofitzRe-rolled for 8.9.x (prior to addressing @larowlan's comments in #85.
Comment #89
jofitzAddressed @larowlan's comments in #85.
Comment #90
mradcliffeThank you for the patch, @jofitz.
I think there may have been some issue with your patch in #88 as it contains git merge conflict data. I think that the next step would be to go back to #83, and try to re-roll this one again. It will most likely have many merge conflicts that you will need to resolve by checking what was intended to be added and putting that back into the relevant spot in the code base as it is today.
After that's done, do as @jofitz did in #89 and apply @larowlan's reviews in #85.
Comment #91
Percy101 commentedI could apply the patch, so no reroll is needed
Comment #92
aleevasWas re-rolled the latest patch
Comment #93
aleevasLets try again
Comment #94
aleevasFixed coding standard error
Comment #95
longwaveAs per #3088246: [policy, no patch] How to handle Drupal 8.9.x deprecations we cannot deprecate in 8.9 for removal in 9.0, unfortunately as this is not critical I think this will have to be deferred until 9.1 now.
Comment #96
meena.bisht commentedComment #97
volegerBack to correct target branch.
Comment #98
meena.bisht commentedSorry, The Target branch is 9.1.x-dev.
Comment #99
meena.bisht commentedAs the #94 patch getting applied on the latest version . So I have rerolled the patch for 9.1.x-dev.
Comment #100
aleevas@meena-bisht
thanks for your help.
But we already on 9.x version. so we no need these deprecated function at all.
So, I've rerolled patch from #94 and removed these deprecation functions
Comment #106
nod_D10 version needed
At this time we would need a D10.1.x patch or MR for this issue.
Comment #107
bhanu951 commentedComment #109
bhanu951 commentedRe Rolled patch 2448545-100.patch to 10.1.x Branch.
Comment #110
spokjeUnhappy TestBot.
Comment #111
bhanu951 commentedUpdated few more occurrences of '_none' .
There is already a constant defined for '_none' in media module any suggestions on how to proceed with replacement of that constant ? should we replace it now or deprecate it now and remove in 11.x or ignore it ? do we have any policy in regards that ?
Comment #112
bhanu951 commentedCreated follow up issue #3324012 to replace
METADATA_FIELD_EMPTYconstant.Comment #114
bhanu951 commentedRebased against 11.x Branch.
Comment #115
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #116
bhanu951 commentedComment #118
dimitriskr commentedRebased branch to 11.x, but getting some Functional tests failures
Comment #119
dimitriskr commentedTests pass
Comment #120
smustgrave commentedTitle + MR title mention deprecating form_select_options but that doesn't appear to be the case.
Comment #121
dimitriskr commentedYou're right, I'll put it back with the trigger_error.
Shall I create a new CR for the deprecation or add it to the current draft?
Comment #122
smustgrave commentedLets do a new one for the deprecation.
Current one could use some love but think adding a constant deserves to be separate.
Comment #123
dimitriskr commentedOK. And one more question. Is
core/tests/Drupal/KernelTests/Core/Forma good place to put the deprecation test?Comment #124
dimitriskr commentedComment #125
smustgrave commentedThink that should be good since the function isn't in a module. Least I can't think of a better spot
Comment #126
dimitriskr commentedUghh the code removes form_get_options() too
Comment #127
dimitriskr commentedComment #128
dimitriskr commentedDon't the new methods need tests for themselves?
Comment #129
dimitriskr commentedComment #132
dimitriskr commentedPlease ignore the change in .gitlab-ci.yml, which is for debugging purposes, all other changes and reported feedback are ready for this issue
Comment #133
smustgrave commentedLeft some feedback.
Comment #134
dimitriskr commentedThanks @smustgrave.
Moreover in #3290812: Deprecate form_get_options() it was proposed to remove
form_get_options()as there is no usage in core and (then) in contrib. We need to see if we still want to do that hereComment #135
dimitriskr commentedIn https://drupal.slack.com/archives/C1BMUQ9U6/p1707853736065729 , catch agreed to remove form_get_options() completely
Comment #136
dimitriskr commentedComment #137
dimitriskr commentedComment #138
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #139
dimitriskr commentedComment #140
smustgrave commentedStill appears to have some open threads in the test. But rest is looking real good.
Comment #143
bhanu951 commentedFixed Tests and updated depreciations.
Tests are passing. Seems its ready for review.
Comment #144
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #145
bhanu951 commentedBot false positive.
Comment #146
bhanu951 commentedRebased to latest head, seems it is ready for review.
Comment #147
smustgrave commentedOnly did a light review but you get the flow.
Overall looks good though.
Comment #148
bhanu951 commentedReview comments addressed.
Comment #149
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #150
dimitriskr commentedComment #151
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #152
dimitriskr commentedComment #153
smustgrave commentedFeedback appears to be address here. I see nothing outstanding.
Comment #154
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #155
godotislateCommented on MR with suggestion to meet CS line length issue flagged by NR bot.
Comment #157
dcam commentedRebased. I applied the comment line length suggestion, but I'm restoring the RTBC status anyway since it's a very minor change.
Comment #158
quietone commentedThe title reads like a list of changes instead it should be a description of what is being fixed or improved. Can this return to the simpler, original title? Remember, The title is used as the git commit message so it should be meaningful and concise. See List of issue fields.
There are two change records here and neither has been reviewed. That needs to be done. However, I don't think we need a change record to announce the new constant. That doesn't fit the criteria in the policy at Change records.
I reviewed the comments and left suggestions and questions.
Comment #159
nicxvan commentedThere are a bunch of suggestions to clean up.
Took a chance on a new title and this feels like it belongs in the form system.
This also need a rebase since the template preprocess fixings have been converted.
Edit: applied the comment suggestions since they make sense to me.
Edit 2:
I'll be honest I think this should be split into two issues.
Issue 1
Deprecate and move form_select_options
Deprecate form_get_options($element
Issue 2
Replace _none with a constant.
Comment #161
nicxvan commentedOk I reduced scope here to just deprecating the two functions and creating one replacement.
I created a follow up for the documentation here: #3548829: [pp-1] Add examples for FormSelectOptions::process it is postponed on this.
I also created an issue for the _none bit here #3548830: Add enum for _none and replace uses it is not postponed, but it should be an enum and can be done in parallel.
I did this on 11.x and went through and addressed all comments and moved the one I did not.
I reviewed the CRs and will move the enum one.
I updated the Issue Summary too.
Assuming tests pass this is ready for review and should be more straightforward to get in now.
I left removal at drupal 12 since form_select_options is not used all that much and it's an easy replacement and form_get_options is not used period.
Comment #163
nicxvan commentedComment #164
nicxvan commentedThis is ready for review, one comment on the MR that might need updating.
Greatly reduced scope this is not likely to conflict again and I created follow ups.
Comment #165
quietone commented@nicxvan, I'm glad you liked my suggestion from #164.
The reduction in scope is helpful here, this is now just one task. There are issues for the remaining tasks.
My points have been addressed so restoring the RTBC.
Comment #166
alexpottLet's not change and move the documentation.. if we're move code and docs let's keep everything the same and then file follow-up issues to improve if necessary but on a quick review many of the changes being made here do not feel like improvements of the no-brainer kind that might be allowed during a code move.
Comment #168
nicxvan commentedOk I rebased this and updated the deprecation versions.
I addressed the comment feedback and reset it to the original, we can do a follow up to modify it.
I added @final, I know nobody should really instantiate this or extend it, but what is the harm if someone does that? Do we really need to fully lock this down?
Comment #169
nicxvan commentedOk I added it.
Comment #170
smustgrave commentedNeeds a rebase please
Comment #171
smustgrave commentedWring MR sorry
Comment #172
smustgrave commentedApologize, I rebased this yesterday as it was 700+ commits back and then got super distracted by work (not fun).
Anyway I bumped the versions to 11.5 since 11.4 is out.
Believe latest feedback has been addressed, CR is basic and straight forward.
All LGTM. My bad again promise wasn't drive by rebasing.
Comment #173
nicxvan commentedThanks, rebase and version bump looks great!
Comment #174
quietone commentedI did another check on this issue. I found errors in the deprecation messages and made suggestions for those, which I have applied. I also updated credit and reviewed the change record.
Leaving at RTBC
Comment #175
nicxvan commentedThank you for those updates, they look great!