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 #2152221 by steveoliver, joelpittet, hussainweb, shanethehat, jenlampton, kpa, AnythonyR, EVIIILJ, kgoel, Cottser, dsdeiz, hanpersand: Convert theme_radios() to Twig
Task
Convert theme_radios() to a Twig template.
Remaining tasks
- Patch
- Patch review
- Manual testing
- Profiling
Steps to test
@todo
Comment | File | Size | Author |
---|---|---|---|
#25 | Screenshot 2014-03-25 13.23.32.jpg | 23.69 KB | LewisNyman |
#25 | Screenshot 2014-03-25 13.15.54.jpg | 24.23 KB | LewisNyman |
#24 | screenshot_2.png | 29.67 KB | jjcarrion |
#19 | interdiff.txt | 1.63 KB | joelpittet |
#19 | 2152221-twig-theme_radios-19.patch | 2.64 KB | joelpittet |
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
rteijeiro CreditAttribution: rteijeiro commentedWorking on this one...
Comment #3
rteijeiro CreditAttribution: rteijeiro commentedLet's see...
Comment #4
rteijeiro CreditAttribution: rteijeiro commentedComment #5
Anonymous (not verified) CreditAttribution: Anonymous commented3: 2152221-convert-theme-radios.patch queued for re-testing.
Comment #6
sheilaj CreditAttribution: sheilaj commentedTested on a two field instances (list and boolean). The markup before and after applying the patch (in #3) was identical. See attached screenshots, with twig debug code in the 'after' shots.
Comment #7
star-szrThanks @sheilaj! I think that means we can remove the "Needs manual testing" tag, but this patch does still need profiling.
Comment #8
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
Profiling test results:
Run 52e4a1c03557c uploaded successfully for drupal-perf-drupalcon.
Run 52e4a1fd8a982 uploaded successfully for drupal-perf-drupalcon.
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52e4a1c03557c&...
Run 52e4a1c03557c uploaded successfully for drupal-perf-drupalcon.
Run 52e4a222581ef uploaded successfully for drupal-perf-drupalcon.
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52e4a1c03557c&...
Comment #9
burgerboydaddy CreditAttribution: burgerboydaddy commentedComment #10
InternetDevels CreditAttribution: InternetDevels commentedFixed comments standards.
Comment #12
star-szrComment #13
joelpittetisset() is not nessasary, i't always initialized in drupal_render()
And the reason it's failing is because the twig template was dropped in patch #10
Comment #14
star-szrTagging as a novice task to add back the lost Twig template and make the change mentioned in #13.
Comment #15
IshaDakota CreditAttribution: IshaDakota commentedComment #16
joelpittetCould you tackle this change too?
+ $variables['children'] = isset($element['#children']) ? $element['#children'] : '';
to
+ $variables['children'] = $element['#children'];
Comment #17
IshaDakota CreditAttribution: IshaDakota commentedOf course!
Sorry, misunderstood the comment before.
Comment #18
joelpittetJust a note, these two lines are doing essentially the same thing.
This line is clobbering any css class that gets passed through
So saying that, we might as well remove the array_merge, which is a heavy function call to merge on one class. Do the $element['#attributes']['class'] assignment and add form-radios.
Remove the @todo, we'll take care of that when we do consolidation.
Comment #19
joelpittetTook care of items in #18 and re-thought them a bit. I left the clobbering $attributes = array() and remove the unset, that's not something we need to deal with in this issue.
Comment #21
joelpittet19: 2152221-twig-theme_radios-19.patch queued for re-testing.
Comment #22
joelpittet19: 2152221-twig-theme_radios-19.patch queued for re-testing.
Comment #23
joelpittetComment #24
jjcarrionIt works fine for me.
I've uploaded a screenshot.
Comment #25
LewisNymanThis looks identical to before, so success! RTBC++
Before:
After:
Comment #26
webchickCommitted and pushed to 8.x. Thanks!
Comment #29
webchickSorry, I messed up the commit credit on this one the first time. Good to know that the "commit-back" comments handle reverts, too. :)