function FileTaxonomyTermTestCase::createAttachFileField
Creates a file field and attaches it to the "Tags" taxonomy vocabulary.
Parameters
$name: The field name of the file field to create.
$uri_scheme: The URI scheme to use for the file field (for example, "private" to create a field that stores private files or "public" to create a field that stores public files).
1 call to FileTaxonomyTermTestCase::createAttachFileField()
- FileTaxonomyTermTestCase::_testTermFile in modules/
file/ tests/ file.test - Runs tests for attaching a file field to a taxonomy term.
File
-
modules/
file/ tests/ file.test, line 279
Class
- FileTaxonomyTermTestCase
- Tests adding a file to a non-node entity.
Code
protected function createAttachFileField($name, $uri_scheme) {
$field = array(
'field_name' => $name,
'type' => 'file',
'settings' => array(
'uri_scheme' => $uri_scheme,
),
'cardinality' => 1,
);
field_create_field($field);
// Attach an instance of it.
$instance = array(
'field_name' => $name,
'label' => 'File',
'entity_type' => 'taxonomy_term',
'bundle' => 'tags',
'required' => FALSE,
'settings' => array(),
'widget' => array(
'type' => 'file_generic',
'settings' => array(),
),
);
field_create_instance($instance);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.