Posted by mlncn on April 10, 2011 at 3:07pm
9 followers
| 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
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
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
Here's a patch.
#4
Looks good to me.
#5
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
#7
#8
The last submitted patch, use-attached-for-css-1122584-4.patch, failed testing.
#9
#6: use-attached-for-css-1122584-4.patch queued for re-testing.
#10
#11
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
Automatically closed -- issue fixed for 2 weeks with no activity.