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 commentedI'm rolling a patch for this.
Comment #4
drnikki commentedComment #5
drnikki 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 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 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 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 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 commented+1 to #19 and the updated IS. Unassigning from myself until it's RTBC again.
Comment #23
subhashuyadav commented- Added #value to above patch
Comment #24
subhashuyadav commentedComment #25
shashikant_chauhan commented@subhashuyadav, Kindly add full stop at the end of statement.
* - #value: (text or numbers) Sets values that cannot be edited by the userComment #26
subhashuyadav commentedThanks @shashikant_chauhan. I have updated the patch. Please review.
Comment #27
shashikant_chauhan commentedThanks, Looks good now.
Comment #28
joachim commentedDoes 'Sets' make sense here? It doesn't set anything, it *is* a value.
Comment #29
shashikant_chauhan commented@joachim, I think below sentence makes more sense here. Let me know your thoughts on this.
Comment #30
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 commentedChanged according to suggestions in #30.
Comment #32
shashikant_chauhan 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 commentedAdded documentation FormElement file as well.
Comment #42
larowlanTypically I think we would say 'mixed' instead of 'text or numbers'
Comment #43
_pratik_Will work on this.
Comment #44
_pratik_Rerolled the patch in #34 and addressed the changes specified in #42 . Attached an diff file for reference.
Comment #45
joachim 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 commentedAdding a patch with the changes suggested in #45.
Comment #47
joachim 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!