Issue #2152229 by steveoliver, rteijeiro, joelpittet, JeroenT, InternetDevels, michamilz, burgerboydaddy, hussainweb, shanethehat, jenlampton, kpa, AnythonyR, EVIIILJ, kgoel, Cottser, dsdeiz, hanpersand: Convert theme_textarea() to Twig

Task

Convert theme_textarea() to a Twig template.

Remaining tasks

  • Patch
  • Patch review
  • Manual testing
  • Profiling

Steps to test

@todo

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

star-szr’s picture

Issue summary: View changes

Adding 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.

rteijeiro’s picture

Status: Active » Needs review
FileSize
3.02 KB

Not sure about including element into twig template. Any ideas?

Status: Needs review » Needs work

The last submitted patch, 2: 2152229-convert-theme-textarea-2.patch, failed testing.

joelpittet’s picture

+++ b/core/modules/system/templates/textarea.html.twig
@@ -0,0 +1,18 @@
+<div{{ wrapper_attributes }}><textarea {{ attributes }}>{{ value }}</textarea></div>

You can remove the space before the {{ attributes }}

That's may be the only issue, or the array_merge may be clobbering something...

rteijeiro’s picture

Status: Needs work » Needs review
FileSize
3.01 KB

Removed whitespace as joelpittet suggested in #4. Let's see if now it works.

joelpittet’s picture

+++ b/core/includes/form.inc
@@ -2575,22 +2575,23 @@ function theme_form($variables) {
+  $variables['wrapper_attributes'] = array(

Oh this need to be wrapped in new Attribute()... a good reason we shouldn't have magic wrapped special case variable keys #2108771: Remove special cased title_attributes and content_attributes for Attribute creation

Status: Needs review » Needs work

The last submitted patch, 5: 2152229-convert-theme-textarea-5.patch, failed testing.

rteijeiro’s picture

Status: Needs work » Needs review
FileSize
3.04 KB

Not sure if I understood it well. Let's see :)

Status: Needs review » Needs work

The last submitted patch, 8: 2152229-convert-theme-textarea-8.patch, failed testing.

star-szr’s picture

Interdiff next time please :)

You got rid of the exceptions! And 2 less fails.

joelpittet’s picture

+++ b/core/includes/form.inc
@@ -2575,34 +2575,36 @@ function theme_form($variables) {
+  $variables['attributes']['class'] = array();
+  $variables['attributes']['class'][] = 'form-textarea';
+  $variables['attributes']['class'] = array_merge($variables['attributes']['class'], $element['#attributes']['class']);

I'm quite sure it has to do with the change in how the attributes are being created. I don't know what _form_set_attributes() really does but glad to see it gone as I doubt it's needed. Though it would be worth checking those failed tests to see what the diff is between the attributes. A debug() call in those tests will help.

JeroenT’s picture

I think _form_set_attributes is needed, because it also adds a required class and other stuff when necessary.

JeroenT’s picture

Status: Needs work » Needs review
JeroenT’s picture

Fixed wrong indentation.

Anonymous’s picture

Added a missing space.

burgerboydaddy’s picture

wrong test; sorry

burgerboydaddy’s picture

Issue tags: -needs profiling
burgerboydaddy’s picture

Issue tags: +needs profiling
burgerboydaddy’s picture

=== 8.x..8.x compared (52e436ce9c71d..52e43719571bf):

ct  : 69,806|69,806|0|0.0%
wt  : 260,668|261,804|1,136|0.4%
cpu : 246,347|247,292|945|0.4%
mu  : 18,775,848|18,777,112|1,264|0.0%
pmu : 18,830,136|18,831,080|944|0.0%

http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52e436ce9c71d&...

=== 8.x..2152229-theme-textarea compared (52e436ce9c71d..52e4374042ace):

ct  : 69,806|70,331|525|0.8%
wt  : 260,668|261,833|1,165|0.4%
cpu : 246,347|247,360|1,013|0.4%
mu  : 18,775,848|18,857,080|81,232|0.4%
pmu : 18,830,136|18,910,312|80,176|0.4%

http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52e436ce9c71d&...

Scenario for this profiling:
0. setup Seven 8.0-dev as default theme
1. added additional field to article content type.
2. created node as article type.
3. setup page as front page
4. allowed anonymous user to view, post, edit, and skip comment approval
5. run tests

burgerboydaddy’s picture

Issue tags: -needs profiling
burgerboydaddy’s picture

Results of manual comparison:
Original - clean

Patched

burgerboydaddy’s picture

Issue tags: -Needs manual testing
burgerboydaddy’s picture

Results of manual comparison:
Original - clean

<div class="form-textarea-wrapper"><textarea class="text-full form-textarea required resize-vertical" id="edit-comment-body-0-value" name="comment_body[0][value]" rows="5" cols="60" placeholder="" required="required" aria-required="true"></textarea></div>
</div>

Patched

<!-- THEME DEBUG -->
<!-- CALL: theme('textarea') -->
<!-- BEGIN OUTPUT from 'core/modules/system/templates/textarea.html.twig' -->
<div class="form-textarea-wrapper"><textarea class="text-full form-textarea required resize-vertical" id="edit-comment-body-0-value" name="comment_body[0][value]" rows="5" cols="60" placeholder="" required="required" aria-required="true"></textarea></div>

<!-- END OUTPUT from 'core/modules/system/templates/textarea.html.twig' -->
joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Great work all! This is ready to go. Patch passes testbot and Profiling and Manual Testing complete.

@burgerboydaddy thanks for the profiling and manual reviews! And joining in on the sprint in Vancouver.

star-szr’s picture

Status: Reviewed & tested by the community » Needs review

Thanks everyone!

+++ b/core/modules/system/templates/textarea.html.twig
@@ -0,0 +1,18 @@
+ @todo: remove this file once http://drupal.org/node/1819284 is resolved.
+ This is identical to core/modules/system/templates/container.html.twig

Do we still need this @todo? It doesn't seem accurate anymore.

joelpittet’s picture

We do not need that in there, That issue can deal with itself when we get to them, I'd rather not commit code with @todo's if we can help it. Please remove:)

star-szr’s picture

Status: Needs review » Needs work
Issue tags: +Novice

Contributor task up for grabs, then!

Remove the two offending lines from the Twig template and post a new patch and interdiff :)

InternetDevels’s picture

Removed deprecated lines and added interdiff :)

Status: Needs review » Needs work

The last submitted patch, 28: convert-theme-textarea-2152229-28.patch, failed testing.

InternetDevels’s picture

snap_x’s picture

Status: Needs work » Needs review

Test passed. Needs review.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice

Thanks @InternetDevels for removing those todo lines.

This has been profiled in #23 and markup compare in #25. Back to RTBC:)

star-szr’s picture

Issue summary: View changes

Adding some folks to the proposed commit message :)

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.