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 #2152211 by rteijeiro, steveoliver, joelpittet, hussainweb, shanethehat, jenlampton, kpa, AnythonyR, EVIIILJ, kgoel, Cottser, dsdeiz, hanpersand: Convert theme_form() to Twig
Task
Convert theme_form() to a Twig template.
Remaining tasks
- Patch
- Patch review
- Manual testing
- Profiling
Steps to test
Look at any form.
Comment | File | Size | Author |
---|---|---|---|
#16 | 2152211-twig-theme-form-6-reroll.patch | 2.2 KB | joelpittet |
#13 | form-without-patch.txt | 32 KB | joelpittet |
#13 | form-with-patch.txt | 32.39 KB | joelpittet |
#13 | Kaleidoscope_–_form-without-patch_txt___form-with-patch_txt.png | 153.57 KB | joelpittet |
#6 | 2152211-convert-theme-form-6.patch | 2.2 KB | IshaDakota |
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 commentedLet's see how I did it :)
Comment #3
mikl CreditAttribution: mikl commentedWorks great.
If you want to test this patch, be aware that app forms disappear after applying it, until you can clear the cache – so if you're not logged in and have loaded the clear cache button already, you'll have to use drush 7 to clear it – a simple `drush cache-rebuild` will do.
Comment #4
star-szrComment #5
star-szrDocs need some tweaking, otherwise this is looking good so far!
This should also add the 'Default template' line per https://drupal.org/node/1354#themepreprocess.
We need to remove the line above @ingroup themeable as well :)
This documentation seems wrong, this should probably be referencing the contents or child elements of the form.
These lines should be removed.
Comment #6
IshaDakota CreditAttribution: IshaDakota commentedEdited patch per comment #5.
Comment #8
star-szr6: 2152211-convert-theme-form-6.patch queued for re-testing.
Comment #9
andypostActual render of form is happens in form builder not sure it's possible to move the whole form render to theme layer, but worst to try
This needs review of someone who knows internals of Form builder|render
This always a rendered string!!!
suppose we need to delegate Form api render of children to theme layer
Comment #10
joelpittetNeeds array type:
@param array $variables.
Comment #11
star-szrRegarding #9 while I support the idea in general I highly recommend that be a separate/follow-up issue.
Comment #12
joelpittetI agree with @Cottser here, the idea would be good, the change may not even be that hard but it's not the goal of this issue and should be a follow-up.
I'm putting this on my plate for profiling. We need to just get this in so we can get suggestions/consolidation/remove the div/get real children, etc.
Comment #13
joelpittetJust for posterity here's another markup comparison.
Comment #14
joelpittetScenario:
3 of each User and Search form blocks added to the front page.
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=530ed1c5bdc6a&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=530ed1c5bdc6a&...
Comment #15
alexpott2152211-convert-theme-form-6.patch no longer applies.
Comment #16
joelpittetPatch applies with 3-way merge, here's a re-roll. Back to RTBC, no changes.
Comment #17
webchickCommitted and pushed to 8.x. Thanks!