In #557272: FAPI: JavaScript States system, we introduced a "container" Form API type which allows the easy creation of div elements. Now that it's available, we should touch it up, and start taking advantage of it in places where we previously used #prefix and #suffix with hardcoded HTML.

Comments

robloach’s picture

Issue tags: +API clean-up, +D7 API clean-up

Adding the clean up tags.

robloach’s picture

Status: Needs review » Needs work
StatusFileSize
new6.29 KB

This patch goes E_STRICT. But wait a second, what happened to #326539: Convert 'class' attribute to use an array, not a string?

sun’s picture

I don't understand the question.

robloach’s picture

I mean, why isn't the class array attribute not working in the patch I posted above?

sun’s picture

Status: Needs work » Needs review

I have no idea, why it shouldn't work. Did you flush your caches?

Also, I'd highly prefer a custom #inline => TRUE property that simply replaces the .form-wrapper CSS class with .container-inline when being set.

sun’s picture

Issue tags: -form API, -D7 API clean-up

Sorry, but I need to clean some tags here.

sun’s picture

+++ modules/system/system.module	3 Nov 2009 21:43:52 -0000
@@ -2545,7 +2545,10 @@
+  $form['actions'] = array(
+    '#type' => 'container',
+    '#attributes' => array('class' => array('container-inline')),
+  );

I'd additionally would like to see a class

'form-actions' here.

This review is powered by Dreditor.

sun’s picture

+++ includes/form.inc	3 Nov 2009 21:43:51 -0000
@@ -2193,7 +2193,10 @@
 function form_process_container($element, &$form_state) {
-  $element['#id'] = drupal_html_id(implode('-', $element['#parents']) . '-wrapper');
+  if (!isset($element['#id'])) {
+    $element['#id'] = drupal_html_id(implode('-', $element['#parents']) . '-wrapper');
+  }
+  $elements['#attributes']['class'][] = 'form-wrapper';
   return $element;

@@ -2211,7 +2213,12 @@
 function theme_container($variables) {
   $element = $variables['element'];
-  return '<div class="form-wrapper" id="' . $element['#id'] . '">' . $element['#children'] . '</div>';
+  // Inject the element's ID into the attributes, if provided.
+  $attributes = isset($element['#attributes']) ? $element['#attributes'] : array();
+  if (isset($element['#id'])) {
+    $attributes['id'] = $element['#id'];
+  }
+  return '<div' . drupal_attributes($attributes) . '>' . $element['#children'] . '</div>';

Note that I already did those changes in another issue elsewhere, which was already committed.

Would be totally awesome to get the other changes of this patch in!

This review is powered by Dreditor.

robloach’s picture

StatusFileSize
new5.85 KB

Rerolled and takes your changes into consideration. Doesn't have #inline as I'm not sure how many new Form API properties we want to add to Drupal 7 ;-) .

sun’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

robloach’s picture

Status: Reviewed & tested by the community » Postponed
asimmonds’s picture

Status: Postponed » Needs review

#482816: Make a consistent wrapper around submit buttons was committed so setting this back to review

Re-test of 622432.patch from comment #9 was requested by sun.

Status: Needs review » Needs work
Issue tags: +DX (Developer Experience), +DrupalWTF, +container, +API clean-up

The last submitted patch, 622432.patch, failed testing.

robloach’s picture

Assigned: robloach » Unassigned
Priority: Normal » Minor
Status: Needs work » Needs review
StatusFileSize
new2.35 KB
lilou’s picture

Status: Needs review » Reviewed & tested by the community

The patch is simple and looks good.

aspilicious’s picture

I found a lot more.
Gonna repatch this tomorrow with everything I find!

aspilicious’s picture

Status: Reviewed & tested by the community » Needs work
jpmckinney’s picture

Status: Needs work » Closed (duplicate)

I looked for other opportunities to use the "container" type, but it looks like #676800-139: Fieldsets break design badly already did that (there are maybe one or two places in each of taxonomy.module, poll.module, and node.module where the "container" type could be used). However, even if we can replace these with the "container" type and not impact functionality, we would still have to test for browser compatibility. So, marking duplicate.