Seen in a few elements such as core/lib/Drupal/Core/Render/Element/Radios.php, core/lib/Drupal/Core/Render/Element/RenderElement.php, core/lib/Drupal/Core/Render/Element/ImageButton.php, but doesn't seem to be documented anywhere.
Update:
- Since #has_garbage_value is only of use on form elements, it should be documented on the FormElement class (even though the code using it is in RenderElement).
- The docs for this property need to reference the #value property, which is also missing from the documentation, so it should also be added to FormElement. You can get some docs for #value from the Drupal 7 Form API reference on api.drupal.org (at least to look at for reference about what it should say):
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.h...
Comment | File | Size | Author |
---|---|---|---|
#46 | 2717921-44_46_interdiff.txt | 1.72 KB | hmendes |
#46 | 2717921-46.patch | 1.81 KB | hmendes |
#44 | reroll_diff_2717921_34-44.txt | 2.27 KB | _pratik_ |
#44 | 2717921-44.patch | 1.8 KB | _pratik_ |
#34 | interdiff-31-34.txt | 807 bytes | gaurav.kapoor |
Comments
Comment #2
jhodgdonThanks for the report! This should be documented on https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!Re...
which lists all of the generic properties.
It seems like the documentation should say that it indicates that the #value property of an element should not be used or processed.
Comment #3
drnikki CreditAttribution: drnikki as a volunteer commentedI'm rolling a patch for this.
Comment #4
drnikki CreditAttribution: drnikki as a volunteer commentedComment #5
drnikki CreditAttribution: drnikki as a volunteer commentedComment #6
jhodgdonLooks good to me, thanks!
Comment #7
Wim LeersI'm not sure it's correct to document this as being a public API. It's something that's internal to Form API.
+
Comment #8
jhodgdonIt is being used by at least one or two elements in Core (being set in their form array defaults) -- so not really strictly internal, I think?
Also we are documenting both internal and public properties in the RenderElement and FormElement class. That said, I think you are right that we should add a note to this documentation to say it's internal.
See
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!Re...
The way we are doing this on other properties is changing (bool) to (bool, internal) at the start of the docs line.
Comment #9
Wim LeersWell, Drupal has internal APIs to work around problems in the API design, I think this is an example of that.
Cool :)
Comment #10
drnikki CreditAttribution: drnikki as a volunteer commentedBased on my understanding of the convo above, I updated the description to (bool, internal) and fixed resulting line wrap.
Comment #11
jhodgdonLooks good, thanks!
Comment #12
Wim Leers+1
Comment #14
jhodgdonStupid Migrate random test failures. I think/hope there is an issue about them.
Comment #15
effulgentsia CreditAttribution: effulgentsia at Acquia commentedThis refers to #value, which is not documented. Also, #value should definitely not be documented on RenderElement, but on FormElement, which makes me think that #has_garbage_value should also be on FormElement, despite RenderElement having code that checks for FAPI-specific properties, which is kind of a shame. I don't want to scope creep this issue too much though, so I'd like to open another issue to delve into these concerns in more detail. Assigning this to myself until I do that.
Comment #16
effulgentsia CreditAttribution: effulgentsia at Acquia commentedMore accurate status per #15.
Comment #17
jhodgdonDoh! #value should definitely be documented too. It seems to me that #has_garbage_value and #value should both be on FormElement, as I think you are suggesting? Independent of where the code is, that is where they logically should be documented for developers to learn about.
Comment #18
effulgentsia CreditAttribution: effulgentsia at Acquia commented+1 to #17. If you're ok with moving the #has_garbage_value docs to FormElement, despite RenderElement having code that uses it, that certainly works for me, and so this doesn't need to be postponed on moving that code.
Do we want to add #value docs in this issue, or postpone this issue on a separate #value docs issue?
Comment #19
jhodgdonIt seems if #has_garbage_value references #value, we should document it in this issue.
Updating summary.
Comment #20
effulgentsia CreditAttribution: effulgentsia at Acquia commented+1 to #19 and the updated IS. Unassigning from myself until it's RTBC again.
Comment #23
subhashuyadav CreditAttribution: subhashuyadav at Valuebound commented- Added #value to above patch
Comment #24
subhashuyadav CreditAttribution: subhashuyadav at Valuebound commentedComment #25
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commented@subhashuyadav, Kindly add full stop at the end of statement.
* - #value: (text or numbers) Sets values that cannot be edited by the user
Comment #26
subhashuyadav CreditAttribution: subhashuyadav at Valuebound commentedThanks @shashikant_chauhan. I have updated the patch. Please review.
Comment #27
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commentedThanks, Looks good now.
Comment #28
joachim CreditAttribution: joachim commentedDoes 'Sets' make sense here? It doesn't set anything, it *is* a value.
Comment #29
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commented@joachim, I think below sentence makes more sense here. Let me know your thoughts on this.
Comment #30
joachim CreditAttribution: joachim commentedLooks better, though I'd tweak it to:
> + * - #value: (text or numbers) A value that cannot be edited by the user.
Comment #31
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedChanged according to suggestions in #30.
Comment #32
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commentedLooks good, thanks
Comment #33
Gábor HojtsyThanks for picking this up! Does not seem like that #15 or #18 was considered though.
Comment #34
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedAdded documentation FormElement file as well.
Comment #42
larowlanTypically I think we would say 'mixed' instead of 'text or numbers'
Comment #43
_pratik_ CreditAttribution: _pratik_ as a volunteer and at Specbee for Drupal India Association commentedWill work on this.
Comment #44
_pratik_ CreditAttribution: _pratik_ as a volunteer and at Specbee for Drupal India Association commentedRerolled the patch in #34 and addressed the changes specified in #42 . Attached an diff file for reference.
Comment #45
joachim CreditAttribution: joachim at Factorial GmbH commentedLooks good, just one thing:
I don't think this way of specifying something is internal is done anywhere else in core.
I would put:
> (bool) Internal only. Set to TRUE [...]
Comment #46
hmendes CreditAttribution: hmendes at CI&T commentedAdding a patch with the changes suggested in #45.
Comment #47
joachim CreditAttribution: joachim at Factorial GmbH commentedLooks great. Thanks!
Comment #48
alexpottCommitted and pushed d909b20df7 to 10.0.x and 52fbb19786 to 9.4.x and 6937f0b4e0 to 9.3.x. Thanks!