Commit 030f536c authored by alexpott's avatar alexpott
Browse files

Issue #2446869 by amateescu: Convert the "Field storage edit" form to an actual entity form

parent c4550b7b
......@@ -340,7 +340,7 @@ public static function fieldSettingsFromConfigData(array $settings);
/**
* Returns a form for the storage-level settings.
*
* Invoked from \Drupal\field_ui\Form\FieldStorageEditForm to allow
* Invoked from \Drupal\field_ui\Form\FieldStorageConfigEditForm to allow
* administrators to configure storage-level settings.
*
* Field storage might reject settings changes that affect the field
......
......@@ -327,14 +327,14 @@ function comment_form_field_ui_display_overview_form_alter(&$form, FormStateInte
}
/**
* Implements hook_form_FORM_ID_alter().
* Implements hook_form_FORM_ID_alter() for 'field_storage_config_edit_form'.
*/
function comment_form_field_ui_field_storage_edit_form_alter(&$form, FormStateInterface $form_state) {
if ($form['#field']->getType() == 'comment') {
function comment_form_field_storage_config_edit_form_alter(&$form, FormStateInterface $form_state) {
if ($form_state->getFormObject()->getEntity()->getType() == 'comment') {
// We only support posting one comment at the time so it doesn't make sense
// to let the site builder choose anything else.
$form['field_storage']['cardinality_container']['cardinality']['#default_value'] = 1;
$form['field_storage']['cardinality_container']['#access'] = FALSE;
$form['cardinality_container']['cardinality']['#default_value'] = 1;
$form['cardinality_container']['#access'] = FALSE;
}
}
......
......@@ -129,7 +129,7 @@ public function testCommentFieldCreate() {
// Select a comment type and try to save again.
$edit = array(
'field_storage[settings][comment_type]' => 'user_comment_type',
'settings[comment_type]' => 'user_comment_type',
);
$this->drupalPostForm('admin/config/people/accounts/fields/user.user.field_user_comment/storage', $edit, t('Save field settings'));
// We shouldn't get an error message.
......
......@@ -265,8 +265,8 @@ function testCommentFunctionality() {
// Test that field to change cardinality is not available.
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment/storage');
$this->assertResponse(200);
$this->assertNoField('field_storage[cardinality_number]');
$this->assertNoField('field_storage[cardinality]');
$this->assertNoField('cardinality_number');
$this->assertNoField('cardinality');
$this->drupalLogin($this->adminUser);
......@@ -413,7 +413,7 @@ function testCommentFunctionality() {
// Add a new comment field.
$storage_edit = array(
'field_storage[settings][comment_type]' => 'foobar',
'settings[comment_type]' => 'foobar',
);
$this->fieldUIAddNewField('entity_test/structure/entity_test', 'foobar', 'Foobar', 'comment', $storage_edit);
......
......@@ -75,10 +75,10 @@ public function testFieldAdminHandler() {
), t('Save and continue'));
// Node should be selected by default.
$this->assertFieldByName('field_storage[settings][target_type]', 'node');
$this->assertFieldByName('settings[target_type]', 'node');
// Check that all entity types can be referenced.
$this->assertFieldSelectOptions('field_storage[settings][target_type]', array_keys(\Drupal::entityManager()->getDefinitions()));
$this->assertFieldSelectOptions('settings[target_type]', array_keys(\Drupal::entityManager()->getDefinitions()));
// Second step: 'Field settings' form.
$this->drupalPostForm(NULL, array(), t('Save field settings'));
......@@ -133,7 +133,7 @@ public function testFieldAdminHandler() {
// specific to its selection handler are displayed.
$field_name = 'node.' . $this->type . '.field_test';
$edit = array(
'field_storage[settings][target_type]' => 'taxonomy_term',
'settings[target_type]' => 'taxonomy_term',
);
$this->drupalPostForm($bundle_path . '/fields/' . $field_name . '/storage', $edit, t('Save field settings'));
$this->drupalGet($bundle_path . '/fields/' . $field_name);
......@@ -143,7 +143,7 @@ public function testFieldAdminHandler() {
// its selection handler are displayed.
$field_name = 'node.' . $this->type . '.field_test';
$edit = array(
'field_storage[settings][target_type]' => 'user',
'settings[target_type]' => 'user',
);
$this->drupalPostForm($bundle_path . '/fields/' . $field_name . '/storage', $edit, t('Save field settings'));
$this->drupalGet($bundle_path . '/fields/' . $field_name);
......@@ -240,7 +240,7 @@ public function createEntityReferenceField($target_type, $bundle = NULL) {
$field_name = strtolower($this->randomMachineName());
$storage_edit = $field_edit = array();
$storage_edit['field_storage[settings][target_type]'] = $target_type;
$storage_edit['settings[target_type]'] = $target_type;
if ($bundle) {
$field_edit['field[settings][handler_settings][target_bundles][' . $bundle . ']'] = TRUE;
}
......
......@@ -68,8 +68,11 @@ function field_ui_entity_type_build(array &$entity_types) {
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
$entity_types['field_config']->setFormClass('delete', 'Drupal\field_ui\Form\FieldConfigDeleteForm');
$entity_types['field_config']->setListBuilderClass('Drupal\field_ui\FieldConfigListBuilder');
$entity_types['field_storage_config']->setFormClass('edit', 'Drupal\field_ui\Form\FieldStorageConfigEditForm');
$entity_types['field_storage_config']->setListBuilderClass('Drupal\field_ui\FieldStorageConfigListBuilder');
$entity_types['field_storage_config']->setLinkTemplate('collection', '/admin/reports/fields');
$entity_types['entity_form_display']->setFormClass('edit', 'Drupal\field_ui\Form\EntityFormDisplayEditForm');
$entity_types['entity_view_display']->setFormClass('edit', 'Drupal\field_ui\Form\EntityViewDisplayEditForm');
}
......
......@@ -2,121 +2,99 @@
/**
* @file
* Contains \Drupal\field_ui\Form\FieldStorageEditForm.
* Contains \Drupal\field_ui\Form\FieldStorageConfigEditForm.
*/
namespace Drupal\field_ui\Form;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\TypedData\TypedDataManager;
use Drupal\field\FieldConfigInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field_ui\FieldUI;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a form for the "field storage" edit page.
*/
class FieldStorageEditForm extends FormBase {
class FieldStorageConfigEditForm extends EntityForm {
/**
* The field being edited.
* The entity being used by this form.
*
* @var \Drupal\field\FieldConfigInterface
* @var \Drupal\field\FieldStorageConfigInterface
*/
protected $field;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* The typed data manager.
*
* @var \Drupal\Core\TypedData\TypedDataManager
*/
protected $typedDataManager;
protected $entity;
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'field_ui_field_storage_edit_form';
}
public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entity_type_id) {
// The URL of this entity form contains only the ID of the field_config
// but we are actually editing a field_storage_config entity.
$field_config = FieldConfig::load($route_match->getRawParameter('field_config'));
/**
* Constructs a new FieldStorageEditForm object.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\TypedData\TypedDataManager $typed_data_manager
* The typed data manager.
*/
public function __construct(EntityManagerInterface $entity_manager, TypedDataManager $typed_data_manager) {
$this->entityManager = $entity_manager;
$this->typedDataManager = $typed_data_manager;
return $field_config->getFieldStorageDefinition();
}
/**
* {@inheritdoc}
*
* @param string $field_config
* The ID of the field config whose field storage config is being edited.
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.manager'),
$container->get('typed_data_manager')
);
public function buildForm(array $form, FormStateInterface $form_state, $field_config = NULL) {
if ($field_config) {
$field = FieldConfig::load($field_config);
$form_state->set('field_config', $field);
$form_state->set('entity_type_id', $field->getTargetEntityTypeId());
$form_state->set('bundle', $field->getTargetBundle());
}
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, FieldConfigInterface $field_config = NULL) {
$this->field = $field_config;
$form_state->set('field', $field_config);
$form['#title'] = $this->field->label();
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$field_storage = $this->field->getFieldStorageDefinition();
$form['#field'] = $field_storage;
$form['#bundle'] = $this->field->bundle;
$description = '<p>' . $this->t('These settings apply to the %field field everywhere it is used. These settings impact the way that data is stored in the database and cannot be changed once data has been created.', array('%field' => $this->field->label())) . '</p>';
// Create a form structure for the field values.
$form['field_storage'] = array(
'#prefix' => $description,
'#tree' => TRUE,
);
$field_label = $form_state->get('field_config')->label();
$form['#title'] = $field_label;
$form['#prefix'] = '<p>' . $this->t('These settings apply to the %field field everywhere it is used. These settings impact the way that data is stored in the database and cannot be changed once data has been created.', array('%field' => $field_label)) . '</p>';
// See if data already exists for this field.
// If so, prevent changes to the field settings.
if ($field_storage->hasData()) {
$form['field_storage']['#prefix'] = '<div class="messages messages--error">' . $this->t('There is data for this field in the database. The field settings can no longer be changed.') . '</div>' . $form['field_storage']['#prefix'];
if ($this->entity->hasData()) {
$form['#prefix'] = '<div class="messages messages--error">' . $this->t('There is data for this field in the database. The field settings can no longer be changed.') . '</div>' . $form['#prefix'];
}
// Add settings provided by the field module. The field module is
// responsible for not returning settings that cannot be changed if
// the field already has data.
$form['field_storage']['settings'] = array(
$form['settings'] = array(
'#weight' => -10,
'#tree' => TRUE,
);
// Create an arbitrary entity object, so that we can have an instantiated
// FieldItem.
$ids = (object) array('entity_type' => $this->field->entity_type, 'bundle' => $this->field->bundle, 'entity_id' => NULL);
$ids = (object) array(
'entity_type' => $form_state->get('entity_type_id'),
'bundle' => $form_state->get('bundle'),
'entity_id' => NULL
);
$entity = _field_create_entity_from_ids($ids);
$items = $entity->get($field_storage->getName());
$items = $entity->get($this->entity->getName());
$item = $items->first() ?: $items->appendItem();
$form['field_storage']['settings'] += $item->storageSettingsForm($form, $form_state, $field_storage->hasData());
$form['settings'] += $item->storageSettingsForm($form, $form_state, $this->entity->hasData());
// Build the configurable field values.
$cardinality = $field_storage->getCardinality();
$form['field_storage']['cardinality_container'] = array(
// Reset #parents to 'field_storage', so the additional container does not appear.
'#parents' => array('field_storage'),
$cardinality = $this->entity->getCardinality();
$form['cardinality_container'] = array(
// Reset #parents so the additional container does not appear.
'#parents' => array(),
'#type' => 'fieldset',
'#title' => $this->t('Allowed number of values'),
'#attributes' => array('class' => array(
......@@ -125,7 +103,7 @@ public function buildForm(array $form, FormStateInterface $form_state, FieldConf
'form-composite'
)),
);
$form['field_storage']['cardinality_container']['cardinality'] = array(
$form['cardinality_container']['cardinality'] = array(
'#type' => 'select',
'#title' => $this->t('Allowed number of values'),
'#title_display' => 'invisible',
......@@ -135,7 +113,7 @@ public function buildForm(array $form, FormStateInterface $form_state, FieldConf
),
'#default_value' => ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) ? FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED : 'number',
);
$form['field_storage']['cardinality_container']['cardinality_number'] = array(
$form['cardinality_container']['cardinality_number'] = array(
'#type' => 'number',
'#default_value' => $cardinality != FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED ? $cardinality : 1,
'#min' => 1,
......@@ -144,79 +122,70 @@ public function buildForm(array $form, FormStateInterface $form_state, FieldConf
'#size' => 2,
'#states' => array(
'visible' => array(
':input[name="field_storage[cardinality]"]' => array('value' => 'number'),
':input[name="cardinality"]' => array('value' => 'number'),
),
'disabled' => array(
':input[name="field_storage[cardinality]"]' => array('value' => -1),
':input[name="cardinality"]' => array('value' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED),
),
),
);
// Build the non-configurable field values.
$form['field_storage']['field_name'] = array('#type' => 'value', '#value' => $field_storage->getName());
$form['field_storage']['type'] = array('#type' => 'value', '#value' => $field_storage->getType());
$form['field_storage']['module'] = array('#type' => 'value', '#value' => $field_storage->getTypeProvider());
$form['field_storage']['translatable'] = array('#type' => 'value', '#value' => $field_storage->isTranslatable());
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Save field settings'),
'#button_type' => 'primary',
);
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
protected function actions(array $form, FormStateInterface $form_state) {
$elements = parent::actions($form, $form_state);
$elements['submit']['#value'] = $this->t('Save field settings');
return $elements;
}
/**
* {@inheritdoc}
*/
public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state);
// Validate field cardinality.
$field_values = $form_state->getValue('field_storage');
$cardinality = $field_values['cardinality'];
$cardinality_number = $field_values['cardinality_number'];
if ($cardinality === 'number' && empty($cardinality_number)) {
$form_state->setErrorByName('field][cardinality_number', $this->t('Number of values is required.'));
if ($form_state->getValue('cardinality') === 'number' && !$form_state->getValue('cardinality_number')) {
$form_state->setErrorByName('cardinality_number', $this->t('Number of values is required.'));
}
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_values = $form_state->getValues();
$field_values = $form_values['field_storage'];
public function buildEntity(array $form, FormStateInterface $form_state) {
// Save field cardinality.
$cardinality = $field_values['cardinality'];
$cardinality_number = $field_values['cardinality_number'];
if ($cardinality === 'number') {
$cardinality = $cardinality_number;
if ($form_state->getValue('cardinality') === 'number' && $form_state->getValue('cardinality_number')) {
$form_state->setValue('cardinality', $form_state->getValue('cardinality_number'));
}
$field_values['cardinality'] = $cardinality;
unset($field_values['container']);
// Merge incoming form values into the existing field.
$field_storage = $this->field->getFieldStorageDefinition();
foreach ($field_values as $key => $value) {
$field_storage->set($key, $value);
}
return parent::buildEntity($form, $form_state);
}
// Update the field.
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$field_label = $form_state->get('field_config')->label();
try {
$field_storage->save();
drupal_set_message($this->t('Updated field %label field settings.', array('%label' => $this->field->label())));
$this->entity->save();
drupal_set_message($this->t('Updated field %label field settings.', array('%label' => $field_label)));
$request = $this->getRequest();
if (($destinations = $request->query->get('destinations')) && $next_destination = FieldUI::getNextDestination($destinations)) {
$request->query->remove('destinations');
$form_state->setRedirectUrl($next_destination);
}
else {
$form_state->setRedirectUrl(FieldUI::getOverviewRouteInfo($this->field->entity_type, $this->field->bundle));
$form_state->setRedirectUrl(FieldUI::getOverviewRouteInfo($form_state->get('entity_type_id'), $form_state->get('bundle')));
}
}
catch (\Exception $e) {
drupal_set_message($this->t('Attempt to update field %label failed: %message.', array('%label' => $this->field->label(), '%message' => $e->getMessage())), 'error');
drupal_set_message($this->t('Attempt to update field %label failed: %message.', array('%label' => $field_label, '%message' => $e->getMessage())), 'error');
}
}
......
......@@ -79,8 +79,8 @@ protected function alterRoutes(RouteCollection $collection) {
$route = new Route(
"$path/fields/{field_config}/storage",
array('_form' => '\Drupal\field_ui\Form\FieldStorageEditForm') + $defaults,
array('_entity_access' => 'field_config.update'),
array('_entity_form' => 'field_storage_config.edit') + $defaults,
array('_permission' => 'administer ' . $entity_type_id . ' fields'),
$options
);
$collection->add("entity.field_config.{$entity_type_id}_storage_edit_form", $route);
......
......@@ -194,7 +194,7 @@ function updateField() {
// Populate the field settings with new settings.
$string = 'updated dummy test string';
$edit = array(
'field_storage[settings][test_field_storage_setting]' => $string,
'settings[test_field_storage_setting]' => $string,
);
$this->drupalPostForm(NULL, $edit, t('Save field settings'));
......@@ -243,22 +243,22 @@ function cardinalitySettings() {
// Assert the cardinality other field cannot be empty when cardinality is
// set to 'number'.
$edit = array(
'field_storage[cardinality]' => 'number',
'field_storage[cardinality_number]' => '',
'cardinality' => 'number',
'cardinality_number' => '',
);
$this->drupalPostForm($field_edit_path, $edit, t('Save field settings'));
$this->assertText('Number of values is required.');
// Submit a custom number.
$edit = array(
'field_storage[cardinality]' => 'number',
'field_storage[cardinality_number]' => 6,
'cardinality' => 'number',
'cardinality_number' => 6,
);
$this->drupalPostForm($field_edit_path, $edit, t('Save field settings'));
$this->assertText('Updated field Body field settings.');
$this->drupalGet($field_edit_path);
$this->assertFieldByXPath("//select[@name='field_storage[cardinality]']", 'number');
$this->assertFieldByXPath("//input[@name='field_storage[cardinality_number]']", 6);
$this->assertFieldByXPath("//select[@name='cardinality']", 'number');
$this->assertFieldByXPath("//input[@name='cardinality_number']", 6);
// Check that tabs displayed.
$this->assertLink(t('Edit'));
......@@ -268,13 +268,13 @@ function cardinalitySettings() {
// Set to unlimited.
$edit = array(
'field_storage[cardinality]' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
);
$this->drupalPostForm($field_edit_path, $edit, t('Save field settings'));
$this->assertText('Updated field Body field settings.');
$this->drupalGet($field_edit_path);
$this->assertFieldByXPath("//select[@name='field_storage[cardinality]']", FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$this->assertFieldByXPath("//input[@name='field_storage[cardinality_number]']", 1);
$this->assertFieldByXPath("//select[@name='cardinality']", FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$this->assertFieldByXPath("//input[@name='cardinality_number']", 1);
}
/**
......
......@@ -128,7 +128,7 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
'#description' => t('This setting only has an effect if the display option is enabled.'),
'#states' => array(
'visible' => array(
':input[name="field_storage[settings][display_field]"]' => array('checked' => TRUE),
':input[name="settings[display_field]"]' => array('checked' => TRUE),
),
),
);
......
......@@ -232,7 +232,7 @@ function testPrivateFileSetting() {
$test_file = $this->getTestFile('text');
// Change the field setting to make its files private, and upload a file.
$edit = array('field_storage[settings][uri_scheme]' => 'private');
$edit = array('settings[uri_scheme]' => 'private');
$this->drupalPostForm("admin/structure/types/manage/$type_name/fields/$field->id/storage", $edit, t('Save field settings'));
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
$node_storage->resetCache(array($nid));
......@@ -247,12 +247,12 @@ function testPrivateFileSetting() {
// Ensure we can't change 'uri_scheme' field settings while there are some
// entities with uploaded files.
$this->drupalGet("admin/structure/types/manage/$type_name/fields/$field->id/storage");
$this->assertFieldByXpath('//input[@id="edit-field-storage-settings-uri-scheme-public" and @disabled="disabled"]', 'public', 'Upload destination setting disabled.');
$this->assertFieldByXpath('//input[@id="edit-settings-uri-scheme-public" and @disabled="disabled"]', 'public', 'Upload destination setting disabled.');
// Delete node and confirm that setting could be changed.
$node->delete();
$this->drupalGet("admin/structure/types/manage/$type_name/fields/$field->id/storage");
$this->assertFieldByXpath('//input[@id="edit-field-storage-settings-uri-scheme-public" and not(@disabled)]', 'public', 'Upload destination setting enabled.');
$this->assertFieldByXpath('//input[@id="edit-settings-uri-scheme-public" and not(@disabled)]', 'public', 'Upload destination setting enabled.');
}
/**
......@@ -275,7 +275,7 @@ function testPrivateFileComment() {
$name = strtolower($this->randomMachineName());
$label = $this->randomMachineName();
$storage_edit = array('field_storage[settings][uri_scheme]' => 'private');
$storage_edit = array('settings[uri_scheme]' => 'private');
$this->fieldUIAddNewField('admin/structure/comment/manage/comment', $name, $label, 'file', $storage_edit);
// Manually clear cache on the tester side.
......
......@@ -110,7 +110,7 @@ public function testDefaultImages() {
$field_id = $field->id();
$this->drupalGet("admin/structure/types/manage/article/fields/$field_id/storage");
$this->assertFieldByXpath(
'//input[@name="field_storage[settings][default_image][uuid][fids]"]',
'//input[@name="settings[default_image][uuid][fids]"]',
$default_images['field']->id(),
format_string(
'Article image field default equals expected file ID of @fid.',
......@@ -131,7 +131,7 @@ public function testDefaultImages() {
// Confirm the defaults are present on the page field settings form.
$this->drupalGet("admin/structure/types/manage/page/fields/$field_id/storage");
$this->assertFieldByXpath(
'//input[@name="field_storage[settings][default_image][uuid][fids]"]',
'//input[@name="settings[default_image][uuid][fids]"]',
$default_images['field']->id(),
format_string(
'Page image field default equals expected file ID of @fid.',
......@@ -183,7 +183,7 @@ public function testDefaultImages() {
// Confirm that the new default is used on the article field settings form.
$this->drupalGet("admin/structure/types/manage/article/fields/$field_id/storage");
$this->assertFieldByXpath(
'//input[@name="field_storage[settings][default_image][uuid][fids]"]',
'//input[@name="settings[default_image][uuid][fids]"]',
$default_images['field_new']->id(),
format_string(
'Updated image field default equals expected file ID of @fid.',
......
......@@ -297,7 +297,7 @@ function testImageFieldSettings() {
// 1, so we need to make sure the file widget prevents these notices by
// providing all settings, even if they are not used.
// @see FileWidget::formMultipleElements().
$this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $field_name . '/storage', array('field_storage[cardinality]' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), t('Save field settings'));
$this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $field_name . '/storage', array('cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), t('Save field settings'));
$edit = array(
'files[' . $field_name . '_1][]' => drupal_realpath($test_image->uri),
);
......@@ -340,9 +340,9 @@ function testImageFieldDefaultImage() {
$alt = $this->randomString(512);
$title = $this->randomString(1024);
$edit = array(
'files[field_storage_settings_default_image_uuid]' => drupal_realpath($images[0]->uri),
'field_storage[settings][default_image][alt]' => $alt,
'field_storage[settings][default_image][title]' => $title,
'files[settings_default_image_uuid]' => drupal_realpath($images[0]->uri),
'settings[default_image][alt]' => $alt,
'settings[default_image][title]' => $title,
);
$this->drupalPostForm("admin/structure/types/manage/article/fields/node.article.$field_name/storage", $edit, t('Save field settings'));
// Clear field definition cache so the new default image is detected.
......@@ -390,7 +390,7 @@ function testImageFieldDefaultImage() {
// Remove default image from the field and make sure it is no longer used.
$edit = array(
'field_storage[settings][default_image][uuid][fids]' => 0,
'settings[default_image][uuid][fids]' => 0,
);
$this->drupalPostForm("admin/structure/types/manage/article/fields/node.article.$field_name/storage", $edit, t('Save field settings'));
// Clear field definition cache so the new default image is detected.
......@@ -404,9 +404,9 @@ function testImageFieldDefaultImage() {
$this->createImageField($private_field_name, 'article', array('uri_scheme' => 'private'));
// Add a default image to the new field.
$edit = array(
'files[field_storage_settings_default_image_uuid]' => drupal_realpath($images[1]->uri),
'