You are here

function nodereference_count_field_instance_settings_form in Nodereference Count 7

Implements hook_field_instance_settings_form().

File

./nodereference_count.module, line 50
Defines a field type for counting the references to a node.

Code

function nodereference_count_field_instance_settings_form($field, $instance) {
  $settings = $instance['settings'];
  $options = nodereference_count_field_options($instance['bundle']);
  $form = array();
  if (empty($options)) {
    $form['counted_reference_fields_empty'] = array(
      '#prefix' => '<p>',
      '#markup' => t('There are no node reference fields to count. If you wish to count the number of references to a node of this type, add a node reference field to another content type, allowing it to reference this content type.'),
      '#suffix' => '</p>',
    );
  }
  else {
    $form['counted_reference_fields'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Nodereference fields that may be counted'),
      '#description' => t('Select the node refence fields that you would like to count.'),
      '#multiple' => TRUE,
      '#default_value' => $settings['counted_reference_fields'],
      '#options' => $options,
    );
    $form['count_only_published'] = array(
      '#type' => 'checkbox',
      '#title' => t('Do not count references from unpublished nodes.'),
      '#default_value' => $settings['count_only_published'],
    );
  }
  return $form;
}