1 file.test FileTestHelper::updateFileField($name, $type_name, $instance_settings = array(), $widget_settings = array())

Updates an existing file field with new settings.

Parameters

string $name: Field name.

string $type_name: Name of the bundle.

array $instance_settings: A list of instance settings that will be added to the instance defaults.

array $widget_settings: A list of widget settings that will be added to the widget defaults.

File

core/modules/file/tests/file.test, line 265
Tests for file.module.

Class

FileTestHelper
Provides methods specifically for testing File module's field handling.

Code

function updateFileField($name, $type_name, $instance_settings = array(), $widget_settings = array()) {
  $instance = field_info_instance('node', $name, $type_name);
  $instance['settings'] = array_merge($instance['settings'], $instance_settings);
  $instance['widget']['settings'] = array_merge($instance['widget']['settings'], $widget_settings);

  field_update_instance($instance);
}