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.
Issue #2152201 by steveoliver, joelpittet, burgerboydaddy, katy5289, hussainweb, shanethehat, jenlampton, kpa, AnythonyR, EVIIILJ, kgoel, Cottser, dsdeiz, hanpersand: Convert theme_checkboxes() to Twig
Task
Convert theme_checkboxes() to a Twig template.
Remaining tasks
- Patch
- Patch review
- Manual testing
- Profiling
Steps to test
- Copy the form_test module from /core/modules/system/tests/modules/form_test/ to /modules/form_test
- Comment out the last line in form_test.info.yml
# hidden: true
- Enable the module
drush en -y form_test
- Visit /form-test/checkboxes-zero/ and compare markup with and without the patch.
Comment | File | Size | Author |
---|---|---|---|
#23 | checkboxes-before-after-23.png | 64.97 KB | Manuel Garcia |
#17 | interdiff.txt | 1.06 KB | joelpittet |
#17 | 2152201-theme_checkboxes-17.patch | 2.85 KB | joelpittet |
#8 | checkboxes-code-comparison.png | 38.82 KB | katy5289 |
#5 | 2152201-theme_checkboxes.patch | 2.95 KB | Salah Messaoud |
Comments
Comment #1
star-szrAdding a commit message to the issue summary so the folks who already worked on #1898480: [meta] form.inc - Convert theme_ functions to Twig and in the Twig sandbox get credit.
Comment #2
joelpittetsplit from twig conversion form meta.
Comment #4
joelpittet2: 2152201-2-theme_checkboxes.patch queued for re-testing.
Comment #5
Salah Messaoud CreditAttribution: Salah Messaoud commentedThis patch applies fine on HEAD as at today's date, I am just getting the testbot to rerun so people can see it is OK
Comment #6
star-szr@Salah Messaoud - thank you for all the rerolls and such :) if you just want to have testbot re-test the patch, please click "Retest" on the appropriate patch. Thanks!
Comment #7
MartiMcFlight CreditAttribution: MartiMcFlight commented5: 2152201-theme_checkboxes.patch queued for re-testing.
Comment #8
katy5289 CreditAttribution: katy5289 commentedCheckboxes for Custom Display Settings are displaying properly. HTML markup generated by the patch looks good. I've attached a screenshot.
Comment #9
joelpittetScenario:
Ran the test at path /form-test/checkboxes-zero/
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52e48e674e7b6&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52e48e674e7b6&...
Comment #10
joelpittetThis has an RTBC from me, but it's my patch so... anybody else can second it:)
Thanks for joining the sprint this weekend @katy5289 and reviewing the patch.
Comment #11
burgerboydaddy CreditAttribution: burgerboydaddy commentedScenario for profiling
1. login as admin
2. select structure; contact form categories
3. select website feedback, click edit
4. go to manage fields
5. add new field
label: some check boxes
field type: list (integer)
6. click on save
7. enter that user must select at least 2 options
list of options:
10|check me 10
11|check me 11
12|check me 12
13|check me 13
14|check me 14
8. Save; go to manage display. select "checkboxes/radio" for display
9. now add another field
label: some radio buttons
field type: list (integer)
10. click on save
11. enter that user must select just 1 option
list of options:
1|check me 1
2|check me 2
3|check me 3
4|check me 4
5|check me 5
12. Save; go to manage display. select "checkboxes/radio" for display
13. go to system settings and enter as default page: /contact
14. now open site, contact form with checkboxes and radio buttons will be displayed.
15. now is good moment to backup database since it can be used again later for radio buttons
test results:
Run 52e49acfb0eb8 uploaded successfully for drupal-perf-drupalcon.
Run 52e49b28a90e1 uploaded successfully for drupal-perf-drupalcon.
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52e49acfb0eb8&...
Run 52e49acfb0eb8 uploaded successfully for drupal-perf-drupalcon.
Run 52e49b394aea8 uploaded successfully for drupal-perf-drupalcon.
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52e49acfb0eb8&...
Comment #12
burgerboydaddy CreditAttribution: burgerboydaddy commentedDAM Joel, you are so fast ;-).
ok, we have 2 sets of result.
Please note that my test was run with twig debugger turned on.
Comment #13
star-szrComment #14
RainbowArrayI tested patch in #5 using the same procedure as descried in #11, and the markup for the checkboxes and radio button is the same before and after the patch.
Looks good to go.
Comment #15
star-szrUpdating suggested commit message to add profilers and manual testers :)
Comment #16
alexpottWhy is this set? And why is it necessary? Perhaps the comment could be improved?
Comment #17
joelpittet@alexpott, the reason behind the unset is that we took away the attribute input clobbering that was done before... but that change probably shouldn't be in this patch and will likely be removed when consolidation with container.html.twig happens. So I added the clobbering back in, removed. Also removed the empty() check on $element['#children'] because it's always initiated in drupal_render().
Setting this back to needs manual testing.
Comment #19
joelpittet17: 2152201-theme_checkboxes-17.patch queued for re-testing.
Comment #20
joelpittet17: 2152201-theme_checkboxes-17.patch queued for re-testing.
Comment #21
joelpittetComment #22
joelpittetAdded steps to test and tagging as novice.
Comment #23
Manuel Garcia CreditAttribution: Manuel Garcia commentedThis looks fine to me, patch applies correctly, and the markup before and after is identical @ /form-test/checkboxes-zero/
Comment #24
joelpittetThank you @Manuel Garcia! The before got cut off a bit in the screenshot for the wrapper for the checkboxes but it is identical, this is taken from 8.x HEAD to compare against your screenshot in #23
<div id="edit-checkbox-zero-default" class="form-checkboxes fieldgroup form-composite">
The rest of the screenshot shows the inside checkboxes which aren't modified with this patch.
Thank you, for the RTBC again:)
Comment #25
Manuel Garcia CreditAttribution: Manuel Garcia commentedOops! thank you for completing it joelpittet =)
Comment #26
webchickCommitted and pushed to 8.x. Thanks!