You are here

function biblio_create_field in Bibliography Module 7.3

Create a biblio field in a bundle.

Parameters

string $field_name: The field name.

string $entity_type: The entity type.

string $bundle: The bundle name.

array $biblio_field: Optional; Array with field definitions, to allow easier overriding by the caller. If empty, function will get the field info by calling biblio_fields_info() with the field name.

5 calls to biblio_create_field()
BiblioStyleBibtex::importData in plugins/biblio_style/bibtex/BiblioStyleBibtex.class.php
@inheritdoc
BiblioStyleEndNoteXML8::importGeneric in plugins/biblio_style/endnote/BiblioStyleEndNoteXML8.php
Import generic property.
biblio_create_fields_by_bundle in ./biblio.module
Attach fields to bundles.
biblio_type_save in ./biblio.module
Save biblio type.
biblio_ui_create_fields_submit in modules/biblio_ui/biblio_ui.module
Submit handler; Attaching the field on the bundle.

File

./biblio.module, line 783
Maintains bibliographic lists.

Code

function biblio_create_field($field_name, $entity_type, $bundle, $biblio_field = array(), $clear_cache = TRUE) {
  if (!$biblio_field && !($biblio_field = biblio_fields_info($field_name))) {
    return;
  }
  $field = field_info_field($field_name);

  // Allow overriding the field name.
  $biblio_field['field']['field_name'] = $field_name;
  if (empty($field)) {
    field_create_field($biblio_field['field']);
  }
  $instance = field_info_instance($entity_type, $field_name, $bundle);
  if (empty($instance)) {
    $instance = $biblio_field['instance'];
    $instance += array(
      'field_name' => $field_name,
      'bundle' => $bundle,
      'entity_type' => $entity_type,
    );
    field_create_instance($instance);
    if ($clear_cache) {
      field_cache_clear();
      entity_property_info_cache_clear();
    }
  }
}