1 entityreference.form.test protected EntityReferenceFormTestCase::createEntityReferenceFieldForNode(array $field, array $field_instance)

Helper method to create a base field and field instance.

Parameters

array $field: The field to be created.

array $field_instance: The field instance to be created.

File

core/modules/entityreference/tests/entityreference.form.test, line 160
Contains EntityReferenceFormTestCase.

Class

EntityReferenceFormTestCase
Test for Entity Reference form.

Code

protected function createEntityReferenceFieldForNode(array $field, array $field_instance) {

  // Add the common settings.
  $field += array(
    'type' => 'entityreference',
    'translatable' => FALSE,
    'entity_types' => array('node'),
  );
  $field_instance += array(
    'entity_type' => 'node',
    'widget' => array(
      'type' => 'entityreference_autocomplete',
      'module' => 'entityreference',
    ),
  );

  $field = field_create_field($field);
  field_create_instance($field_instance);
}