Download & Extend

Use #attached for block_admin_display_form() instead of drupal_add_css()

Project:Drupal core
Version:7.x-dev
Component:block.module
Category:bug report
Priority:minor
Assigned:Unassigned
Status:closed (fixed)
Issue tags:dgd7, needs backport to D7, Novice

Issue Summary

The form provided in this function is a renderable element and should use the more flexible #attached property rather than drupal_add_css() in the function.

Comments

#1

Status:active» needs review

Drupal newbie here.
Can you please let me know where in the form tree does the #attached go?
I am trying to add it to the $form['blocks']. Is this right?

<?php
  $form
['blocks'] = array(
   
'#attached' => array(
     
'css' => array(drupal_get_path('module', 'block') . '/block.css')
    )
  );
?>

#2

Status:needs review» needs work

Not sure. I would rather write

<?php
  $form
['#attached']['css'] = array(
   
drupal_get_path('module', 'block') . '/block.css'),
  );
?>

Basically just removing the "blocks" entry, because it needs to be attached to the whole form. Read the Form API reference on api.drupal.org.
You should try to provide a patch for this.

#3

Status:needs work» needs review

Here's a patch.

AttachmentSizeStatusTest resultOperations
use-attached-for-css-1122584-3.patch619 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 32,908 pass(es).View details

#4

Status:needs review» reviewed & tested by the community

Looks good to me.

#5

Issue tags:+needs backport to D7

Committed to 8.x. This is a candidate for backporting to 7.x. I'm moving this to webchick's queue so she can consider committing this to 7.x.

#6

Status:reviewed & tested by the community» needs review
AttachmentSizeStatusTest resultOperations
use-attached-for-css-1122584-4.patch607 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 36,065 pass(es).View details

#7

Version:8.x-dev» 7.x-dev
Issue tags:-needs backport to D7

#8

Status:needs review» needs work

The last submitted patch, use-attached-for-css-1122584-4.patch, failed testing.

#9

Status:needs work» needs review

#6: use-attached-for-css-1122584-4.patch queued for re-testing.

#10

Status:needs review» reviewed & tested by the community

#11

Status:reviewed & tested by the community» fixed
Issue tags:+needs backport to D7

This doesn't look like it'll change anything as far as what CSS is shown on the page; merely how it's added.

Committed and pushed to 7.x. Thanks!

#12

Status:fixed» closed (fixed)

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