function node_form_block_form_alter

Implements hook_form_FORM_ID_alter() for block_form().

Adds node-type specific visibility options to block configuration form.

File

drupal/core/modules/node/node.module, line 1959
The core module that allows content to be submitted to the site.

Code

function node_form_block_form_alter(&$form, &$form_state) {
  $block = $form_state['controller']
    ->getEntity();
  $visibility = $block
    ->get('visibility');
  $form['visibility']['node_type'] = array(
    '#type' => 'details',
    '#title' => t('Content types'),
    '#collapsed' => TRUE,
    '#group' => 'visibility',
    '#weight' => 5,
  );
  $form['visibility']['node_type']['types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Show block for specific content types'),
    '#default_value' => !empty($visibility['node_type']['types']) ? $visibility['node_type']['types'] : array(),
    '#options' => node_type_get_names(),
    '#description' => t('Show this block only on pages that display content of the given type(s). If you select no types, there will be no type-specific limitation.'),
  );
}