How to add custom fields to blocks in Drupal 7?

Dustin picture Dustin · Jan 5, 2012 · Viewed 13.8k times · Source

I'd like to be able to add custom fields to blocks in Drupal? I have a header area that spans the entire width of the page. Below that will be a left column for body content and right sidebar for various blocks. The header area needs to have a background image with text displayed on top of it. Was hoping to do this through blocks with custom fields for the background image and text.

Answer

i.bajrai picture i.bajrai · Sep 20, 2012

The better way would be to make a custom block in your code using hook_block_info() and hook_pages_block_view(). Then add the additional fields via hook_block_configure().

Using the form api you can then add any type of field you want.