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.
UI used #rows for form element for textarea and select
But select element should use #size
Comment | File | Size | Author |
---|---|---|---|
#3 | 1675052-3.patch | 753 bytes | TR |
| |||
#1 | 1675052-rows2size-1.patch | 933 bytes | andypost |
|
Comments
Comment #1
andypostLet's get 5 lines for select with multiple items
Comment #2
mitchell CreditAttribution: mitchell commentedThis changed the message type dropdown in "Show a system message" to a select list. Could you please show screenshots of the intended effect for this patch?
Comment #3
TR CreditAttribution: TR commentedRe #2:
I assume you mean "Show a message on the site" ... Regardless, I can't reproduce that - it still shows a textarea for me after applying the patch and clearing the cache and verifying that the patch did indeed change the #size of selects.
I don't consider this a bug, because specifying #rows for a select element isn't wrong - the Form API allows us to use and pass around whatever arbitrary properties we want. The Form API just doesn't understand #rows for a select element, and will therefore ignore it. It doesn't generate an error, and doesn't output the wrong thing, because ANY property is allowed (as it might be added deliberately by custom code for internal use).
After trying out the patch, I noticed that if we do specify #size for selects, then the select will ALWAYS have that number of rows shown. I don't like this because if there are only two choices (e.g. "True" and "False") then there will still be 5 rows shown if #size=5. Whereas if we don't specify #size at all, then the default is 4 but it will only show 2 rows if only 2 choices are available. I think that is better.
So here is a new patch that removes the #rows property from the select element but keeps it for the textarea. It does NOT add #size to the select, as that is not needed. This patch does not affect the rendered HTML at all.
Comment #5
TR CreditAttribution: TR commentedCommitted.