You are here

function noderelationships_cck_backref_create in Node Relationships 6

Create a back reference field.

Parameters

$field_options: An array with the following elements:

  • type_name The content type where the is about to be created.
  • field_name The name of the new field.
  • label The label of the new field.
  • referrer_type The referrer content type.
  • referrer_field The name of the nodereference field in the referrer type.
1 call to noderelationships_cck_backref_create()
noderelationships_cck_backref_sync_fields in ./noderelationships.inc
Synchronize back reference settings with back reference fields.

File

./noderelationships.inc, line 616
Common functions for the noderelationships module.

Code

function noderelationships_cck_backref_create($field_options) {

  // Load the Create/Read/Update/Delete library for CCK objects.
  module_load_include('inc', 'content', 'includes/content.crud');

  // Build the field structure.
  $field = array(
    'label' => $field_options['label'],
    'field_name' => $field_options['field_name'],
    'type_name' => $field_options['type_name'],
    'type' => 'noderelationships_backref',
    'widget_type' => 'noderelationships_backref',
    'module' => 'noderelationships',
    'widget_module' => 'noderelationships',
    'required' => 0,
    'multiple' => 0,
    'description' => '',
    'default_value' => NULL,
    'default_value_php' => NULL,
    'default_value_widget' => NULL,
    'columns' => array(),
    'weight' => noderelationships_get_element_weight($field_options['type_name']),
    // Global field settings.
    'referrer_type' => $field_options['referrer_type'],
    'referrer_field' => $field_options['referrer_field'],
  );

  // Create the field.
  content_field_instance_create($field, FALSE);
}