I've found that when creating a form, I mindlessly try to pull in the first field in the palette to demonstrate form builder. This currently is a "Date" component, which is there because it is listed first in the "components" directory of the webform module. It's not even alphabetical, which would have put "Checkboxes" first. I think that we should put these fields in an order that makes sense by usage, but in order to do that we need to add a "weight" property to hook_form_builder_types(). This isn't too difficult.
Now the order of the fields is somewhat tricky, as we should try to "group" fields that are related, as well as put more common fields near the top of the palette, as the top ones are naturally pulled out first (for me at least). At first I grouped things so that they looked "good" in rows, but I realized that some people might want a single column of fields, such as the way Webform Alt UI arranges things or if someone uses CSS to make it a single column (such as in #1463408: Components should not be in two columns).
So the weights I arrived at are somewhat arbitrary, but they work well by putting "popular" components up top, as well as grouping like fields together:
-20 textfield
-19 textarea
-18 email
-17 number
-7 radios
-6 checkboxes
-5 select
-4 grid
6 file
8 hidden
12 date
13 time
17 markup
19 fieldset
20 pagebreak
This patch both adds the weight property ability, and sets these defaults.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | form_builder_weight.patch | 6.03 KB | quicksketch |
| form_builder_weight.patch | 6.03 KB | quicksketch |
Comments
Comment #1
quicksketchAfter one more look, I thought moving "date" and "time" above "file" and "hidden" made sense, so the final structure is:
Comment #2
quicksketchCommitted to both branches.