You are here

function FileFieldTestCase::createFileField in FileField 6.3

Create a new file field.

Parameters

$name: The name of the new field (all lowercase), exclude the "field_" prefix.

$type: The node type that this field will be added to.

$field_options: A list of field options that will be added to the defaults.

$widget_options: A list of widget options that will be added to the widget defaults.

4 calls to FileFieldTestCase::createFileField()
FileFieldDisplayTestCase::testNodeDisplay in tests/filefield.test
Test normal formatter display on node display.
FileFieldPathTestCase::testUploadPath in tests/filefield.test
Test normal formatter display on node display.
FileFieldRevisionTestCase::testRevisions in tests/filefield.test
Test creating multiple revisions of a node and managing the attached files.
FileFieldValidateTestCase::setUp in tests/filefield.test
Implementation of setUp().

File

tests/filefield.test, line 47

Class

FileFieldTestCase

Code

function createFileField($name, $type, $field_options = array(), $widget_options = array()) {
  module_load_include('inc', 'content', 'includes/content.crud');
  $field = array(
    'label' => $name,
    'field_name' => $name,
    'type' => 'filefield',
    'widget_type' => 'filefield_widget',
    'weight' => 0,
    'parent' => 0,
    'type_name' => $type,
    'list_field' => 0,
    'list_default' => 1,
    'description_field' => 0,
  );
  $field = array_merge($field, $field_options);
  $field = content_field_instance_create($field);
  $widget = array(
    'type' => 'filefield_widget',
    'file_extensions' => '',
  );
  $field['widget'] = array_merge($field['widget'], $widget, $widget_options);
  $field = content_field_instance_update($field);
  return $field;
}