You are here

function nodeformsettings_process_format in Node and Comments Form Settings 7.3

Same name and namespace in other branches
  1. 7.2 nodeformsettings.module \nodeformsettings_process_format()

Custom callback function to process input format for all the fields.

Parameters

array $element: The input element for which the format is to be processed.

Return value

array Return updated element with necessary changes.

1 string reference to 'nodeformsettings_process_format'
nodeformsettings_element_info_alter in ./nodeformsettings.module
Implements hook_element_info_alter().

File

./nodeformsettings.module, line 287

Code

function nodeformsettings_process_format($element) {
  $element = filter_process_format($element);

  // Make sure we have an entity and a type here.
  if (isset($element['#entity'], $element['#entity']->type)) {

    // For node type, the '->type' field is available.
    $type = $element['#entity']->type;

    // Array of field names to restrict. Default body.
    $fields = array(
      'body',
    );

    // Get settings for this node type.
    $settings = nodeformsettings_get_settings($type);
    $setting = 'nfs_inputformat';

    // Hide the 'text format' pane below certain text area fields.
    if (isset($settings[$setting], $element['#field_name']) && count($settings) && $settings[$setting] == 1 && in_array($element['#field_name'], $fields)) {

      // Set access to FALSE.
      $element['format']['#access'] = FALSE;
    }
  }
  elseif (isset($element['#entity'], $element['#entity']->node_type) && module_exists('commentformsettings')) {
    $element = commentformsettings_process_format($element);
  }
  return $element;
}