Commit 95dc3178 authored by alexpott's avatar alexpott

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

parent 3425c65b
......@@ -364,7 +364,7 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
/**
* Returns a form for the field-level settings.
*
* Invoked from \Drupal\field_ui\Form\FieldEditForm to allow
* Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow
* administrators to configure field-level settings.
*
* @param array $form
......
......@@ -192,7 +192,7 @@ public function generateSampleItems($count = 1);
/**
* Returns a form for the default value input.
*
* Invoked from \Drupal\field_ui\Form\FieldEditForm to allow
* Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow
* administrators to configure instance-level default value.
*
* @param array $form
......@@ -208,7 +208,7 @@ public function defaultValuesForm(array &$form, FormStateInterface $form_state);
/**
* Validates the submitted default value.
*
* Invoked from \Drupal\field_ui\Form\FieldEditForm to allow
* Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow
* administrators to configure instance-level default value.
*
* @param array $element
......@@ -223,7 +223,7 @@ public function defaultValuesFormValidate(array $element, array &$form, FormStat
/**
* Processes the submitted default value.
*
* Invoked from \Drupal\field_ui\Form\FieldEditForm to allow
* Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow
* administrators to configure instance-level default value.
*
* @param array $element
......
......@@ -19,7 +19,7 @@
/**
* Returns a form to configure settings for the formatter.
*
* Invoked from \Drupal\field_ui\Form\FieldEditForm to allow
* Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow
* administrators to configure the formatter. The field_ui module takes care
* of handling submitted form values.
*
......
......@@ -25,7 +25,7 @@
/**
* Returns a form to configure settings for the widget.
*
* Invoked from \Drupal\field_ui\Form\FieldEditForm to allow
* Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow
* administrators to configure the widget. The field_ui module takes care of
* handling submitted form values.
*
......
......@@ -393,14 +393,14 @@ function testCommentFunctionality() {
// Test comment option change in field settings.
$edit = array(
'default_value_input[comment][0][status]' => CommentItemInterface::CLOSED,
'field[settings][anonymous]' => COMMENT_ANONYMOUS_MAY_CONTACT,
'settings[anonymous]' => COMMENT_ANONYMOUS_MAY_CONTACT,
);
$this->drupalPostForm(NULL, $edit, t('Save settings'));
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0');
$this->assertFieldChecked('edit-default-value-input-comment-0-status-1');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-2');
$this->assertFieldByName('field[settings][anonymous]', COMMENT_ANONYMOUS_MAY_CONTACT);
$this->assertFieldByName('settings[anonymous]', COMMENT_ANONYMOUS_MAY_CONTACT);
// Add a new comment-type.
$bundle = CommentType::create(array(
......
......@@ -318,13 +318,13 @@ function content_translation_entity_extra_field_info() {
}
/**
* Implements hook_form_FORM_ID_alter() for 'field_ui_field_edit_form'.
* Implements hook_form_FORM_ID_alter() for 'field_config_edit_form'.
*/
function content_translation_form_field_ui_field_edit_form_alter(array &$form, FormStateInterface $form_state) {
$field = $form_state->get('field');
function content_translation_form_field_config_edit_form_alter(array &$form, FormStateInterface $form_state) {
$field = $form_state->getFormObject()->getEntity();
$bundle_is_translatable = \Drupal::service('content_translation.manager')->isEnabled($field->entity_type, $field->bundle);
$form['field']['translatable'] = array(
$form['translatable'] = array(
'#type' => 'checkbox',
'#title' => t('Users may translate this field'),
'#default_value' => $field->isTranslatable(),
......@@ -338,7 +338,7 @@ function content_translation_form_field_ui_field_edit_form_alter(array &$form, F
$toggle_url = \Drupal::url('language.content_settings_page', array(), array(
'query' => drupal_get_destination(),
));
$form['field']['translatable']['#description'] = t('To configure translation for this field, <a href="@language-settings-url">enable language support</a> for this type.', array(
$form['translatable']['#description'] = t('To configure translation for this field, <a href="@language-settings-url">enable language support</a> for this type.', array(
'@language-settings-url' => $toggle_url,
));
}
......@@ -347,8 +347,8 @@ function content_translation_form_field_ui_field_edit_form_alter(array &$form, F
module_load_include('inc', 'content_translation', 'content_translation.admin');
$element = content_translation_field_sync_widget($field);
if ($element) {
$form['field']['third_party_settings']['content_translation']['translation_sync'] = $element;
$form['field']['third_party_settings']['content_translation']['translation_sync']['#weight'] = -10;
$form['third_party_settings']['content_translation']['translation_sync'] = $element;
$form['third_party_settings']['content_translation']['translation_sync']['#weight'] = -10;
}
}
}
......
......@@ -174,7 +174,7 @@ function testSettingsUI() {
// Test that also the Field UI form behaves correctly.
$translatable = !$translatable;
$edit = array('field[translatable]' => $translatable);
$edit = array('translatable' => $translatable);
$this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.body', $edit, t('Save settings'));
\Drupal::entityManager()->clearCachedFieldDefinitions();
$field = FieldConfig::loadByName('node', 'article', 'body');
......@@ -242,7 +242,7 @@ function testFieldTranslatableSettingsUI() {
// translatable.
$path = 'admin/structure/types/manage/article/fields/node.article.field_article_text';
$this->drupalGet($path);
$this->assertFieldByXPath('//input[@id="edit-field-translatable" and @disabled="disabled"]');
$this->assertFieldByXPath('//input[@id="edit-translatable" and @disabled="disabled"]');
$this->assertText('To configure translation for this field, enable language support for this type.', 'No translatable setting for field.');
// Tests that field has translatable setting if bundle is translatable.
......@@ -255,7 +255,7 @@ function testFieldTranslatableSettingsUI() {
);
$this->assertSettings('node', 'article', TRUE, $edit);
$this->drupalGet($path);
$this->assertFieldByXPath('//input[@id="edit-field-translatable" and not(@disabled) and @checked="checked"]');
$this->assertFieldByXPath('//input[@id="edit-translatable" and not(@disabled) and @checked="checked"]');
$this->assertNoText('To enable translation of this field, enable language support for this type.', 'Translatable setting for field available.');
}
......
......@@ -88,11 +88,11 @@ function testImageFieldSync() {
// Check that the alt and title fields are enabled for the image field.
$this->drupalLogin($this->editor);
$this->drupalGet('entity_test_mul/structure/' . $this->entityTypeId . '/fields/' . $this->entityTypeId . '.' . $this->entityTypeId . '.' . $this->fieldName);
$this->assertFieldChecked('edit-field-third-party-settings-content-translation-translation-sync-alt');
$this->assertFieldChecked('edit-field-third-party-settings-content-translation-translation-sync-title');
$this->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-alt');
$this->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-title');
$edit = array(
'field[third_party_settings][content_translation][translation_sync][alt]' => FALSE,
'field[third_party_settings][content_translation][translation_sync][title]' => FALSE,
'third_party_settings[content_translation][translation_sync][alt]' => FALSE,
'third_party_settings[content_translation][translation_sync][title]' => FALSE,
);
$this->drupalPostForm(NULL, $edit, t('Save settings'));
......
......@@ -9,16 +9,13 @@
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
use Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\OptGroup;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TypedData\OptionsProviderInterface;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\Core\Validation\Plugin\Validation\Constraint\AllowedValuesConstraint;
use Drupal\field\FieldStorageConfigInterface;
/**
* Alternative plugin implementation of the 'entity_reference' field type.
......@@ -128,7 +125,7 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$field = $form_state->get('field');
$field = $form_state->getFormObject()->getEntity();
// Get all selection plugins for this entity type.
$selection_plugins = \Drupal::service('plugin.manager.entity_reference_selection')->getSelectionGroups($this->getSetting('target_type'));
......@@ -192,7 +189,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
}
/**
* Form element validation handler; Stores the new values in the form state.
* Form element validation handler; Invokes selection plugin's validation.
*
* @param array $form
* The form where the settings form is being included in.
......@@ -200,13 +197,9 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
* The form state of the (entire) configuration form.
*/
public static function fieldSettingsFormValidate(array $form, FormStateInterface $form_state) {
if ($form_state->hasValue('field')) {
$form_state->unsetValue(array('field', 'settings', 'handler_submit'));
$form_state->get('field')->settings = $form_state->getValue(['field', 'settings']);
$handler = \Drupal::service('plugin.manager.entity_reference_selection')->getSelectionHandler($form_state->get('field'));
$handler->validateConfigurationForm($form, $form_state);
}
$field = $form_state->getFormObject()->getEntity();
$handler = \Drupal::service('plugin.manager.entity_reference_selection')->getSelectionHandler($field);
$handler->validateConfigurationForm($form, $form_state);
}
/**
......
......@@ -84,40 +84,40 @@ public function testFieldAdminHandler() {
$this->drupalPostForm(NULL, array(), t('Save field settings'));
// The base handler should be selected by default.
$this->assertFieldByName('field[settings][handler]', 'default:node');
$this->assertFieldByName('settings[handler]', 'default:node');
// The base handler settings should be displayed.
$entity_type_id = 'node';
$bundles = entity_get_bundles($entity_type_id);
foreach ($bundles as $bundle_name => $bundle_info) {
$this->assertFieldByName('field[settings][handler_settings][target_bundles][' . $bundle_name . ']');
$this->assertFieldByName('settings[handler_settings][target_bundles][' . $bundle_name . ']');
}
reset($bundles);
// Test the sort settings.
// Option 0: no sort.
$this->assertFieldByName('field[settings][handler_settings][sort][field]', '_none');
$this->assertNoFieldByName('field[settings][handler_settings][sort][direction]');
$this->assertFieldByName('settings[handler_settings][sort][field]', '_none');
$this->assertNoFieldByName('settings[handler_settings][sort][direction]');
// Option 1: sort by field.
$this->drupalPostAjaxForm(NULL, array('field[settings][handler_settings][sort][field]' => 'nid'), 'field[settings][handler_settings][sort][field]');
$this->assertFieldByName('field[settings][handler_settings][sort][direction]', 'ASC');
$this->drupalPostAjaxForm(NULL, array('settings[handler_settings][sort][field]' => 'nid'), 'settings[handler_settings][sort][field]');
$this->assertFieldByName('settings[handler_settings][sort][direction]', 'ASC');
// Test that a non-translatable base field is a sort option.
$this->assertFieldByXPath("//select[@name='field[settings][handler_settings][sort][field]']/option[@value='nid']");
$this->assertFieldByXPath("//select[@name='settings[handler_settings][sort][field]']/option[@value='nid']");
// Test that a translatable base field is a sort option.
$this->assertFieldByXPath("//select[@name='field[settings][handler_settings][sort][field]']/option[@value='title']");
$this->assertFieldByXPath("//select[@name='settings[handler_settings][sort][field]']/option[@value='title']");
// Test that a configurable field is a sort option.
$this->assertFieldByXPath("//select[@name='field[settings][handler_settings][sort][field]']/option[@value='body.value']");
$this->assertFieldByXPath("//select[@name='settings[handler_settings][sort][field]']/option[@value='body.value']");
// Set back to no sort.
$this->drupalPostAjaxForm(NULL, array('field[settings][handler_settings][sort][field]' => '_none'), 'field[settings][handler_settings][sort][field]');
$this->assertNoFieldByName('field[settings][handler_settings][sort][direction]');
$this->drupalPostAjaxForm(NULL, array('settings[handler_settings][sort][field]' => '_none'), 'settings[handler_settings][sort][field]');
$this->assertNoFieldByName('settings[handler_settings][sort][direction]');
// Third step: confirm.
$this->drupalPostForm(NULL, array(
'field[required]' => '1',
'field[settings][handler_settings][target_bundles][' . key($bundles) . ']' => key($bundles),
'required' => '1',
'settings[handler_settings][target_bundles][' . key($bundles) . ']' => key($bundles),
), t('Save settings'));
// Check that the field appears in the overview form.
......@@ -137,7 +137,7 @@ public function testFieldAdminHandler() {
);
$this->drupalPostForm($bundle_path . '/fields/' . $field_name . '/storage', $edit, t('Save field settings'));
$this->drupalGet($bundle_path . '/fields/' . $field_name);
$this->assertFieldByName('field[settings][handler_settings][auto_create]');
$this->assertFieldByName('settings[handler_settings][auto_create]');
// Switch the target type to 'user' and check that the settings specific to
// its selection handler are displayed.
......@@ -147,13 +147,13 @@ public function testFieldAdminHandler() {
);
$this->drupalPostForm($bundle_path . '/fields/' . $field_name . '/storage', $edit, t('Save field settings'));
$this->drupalGet($bundle_path . '/fields/' . $field_name);
$this->assertFieldByName('field[settings][handler_settings][filter][type]', '_none');
$this->assertFieldByName('settings[handler_settings][filter][type]', '_none');
// Try to select the views handler.
$edit = array(
'field[settings][handler]' => 'views',
'settings[handler]' => 'views',
);
$this->drupalPostAjaxForm($bundle_path . '/fields/' . $field_name, $edit, 'field[settings][handler]');
$this->drupalPostAjaxForm($bundle_path . '/fields/' . $field_name, $edit, 'settings[handler]');
$this->drupalPostForm(NULL, $edit, t('Save settings'));
$this->assertResponse(200);
}
......@@ -242,7 +242,7 @@ public function createEntityReferenceField($target_type, $bundle = NULL) {
$storage_edit = $field_edit = array();
$storage_edit['settings[target_type]'] = $target_type;
if ($bundle) {
$field_edit['field[settings][handler_settings][target_bundles][' . $bundle . ']'] = TRUE;
$field_edit['settings[handler_settings][target_bundles][' . $bundle . ']'] = TRUE;
}
$this->fieldUIAddNewField($bundle_path, $field_name, NULL, 'entity_reference', $storage_edit, $field_edit);
......
......@@ -146,7 +146,7 @@ public function testSupportedEntityTypesAndWidgets() {
'default_value_input[' . $this->fieldName . '][0][target_id]' => $referenced_entities[0]->label() . ' (' . $referenced_entities[0]->id() . ')',
);
if ($key == 'content') {
$field_edit['field[settings][handler_settings][target_bundles][' . $referenced_entities[0]->getEntityTypeId() . ']'] = TRUE;
$field_edit['settings[handler_settings][target_bundles][' . $referenced_entities[0]->getEntityTypeId() . ']'] = TRUE;
}
$this->drupalPostForm($this->entityType . '/structure/' . $this->bundle .'/fields/' . $this->entityType . '.' . $this->bundle . '.' . $this->fieldName, $field_edit, t('Save settings'));
// Ensure the configuration has the expected dependency on the entity that
......
......@@ -121,7 +121,7 @@ function testBooleanField() {
// Test if we can change the on label.
$on = $this->randomMachineName();
$edit = array(
'field[settings][on_label]' => $on,
'settings[on_label]' => $on,
);
$this->drupalPostForm('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field_name, $edit, t('Save settings'));
// Check if we see the updated labels in the creation form.
......@@ -179,8 +179,8 @@ function testBooleanField() {
// Test the boolean field settings.
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field_name);
$this->assertFieldById('edit-field-settings-on-label', $on);
$this->assertFieldById('edit-field-settings-off-label', $off);
$this->assertFieldById('edit-settings-on-label', $on);
$this->assertFieldById('edit-settings-off-label', $off);
}
}
......@@ -113,8 +113,8 @@ function testBooleanFormatterSettings() {
// Set up the field settings.
$this->drupalGet('admin/structure/types/manage/' . $this->bundle . '/fields/node.' . $this->bundle . '.' . $this->fieldName);
$this->drupalPostForm(NULL, array(
'field[settings][on_label]' => $values[0],
'field[settings][off_label]' => $values[1],
'settings[on_label]' => $values[0],
'settings[off_label]' => $values[1],
), 'Save settings');
// Open the Manage Display page and trigger the field settings form.
......
......@@ -517,7 +517,7 @@ function assertSetMinimumValue($field, $minimum_value) {
// Set the minimum value.
$edit = array(
'field[settings][min]' => $minimum_value,
'settings[min]' => $minimum_value,
);
$this->drupalPostForm($field_configuration_url, $edit, t('Save settings'));
// Check if an error message is shown.
......@@ -526,6 +526,6 @@ function assertSetMinimumValue($field, $minimum_value) {
$this->assertRaw(t('Saved %label configuration.', array('%label' => $field->getLabel())));
// Check if the minimum value was actually set.
$this->drupalGet($field_configuration_url);
$this->assertFieldById('edit-field-settings-min', $minimum_value, 'Minimal ' . gettype($minimum_value) .' value was set on a ' . $field->getType() . ' field.');
$this->assertFieldById('edit-settings-min', $minimum_value, 'Minimal ' . gettype($minimum_value) .' value was set on a ' . $field->getType() . ' field.');
}
}
......@@ -66,6 +66,7 @@ function field_ui_theme() {
*/
function field_ui_entity_type_build(array &$entity_types) {
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
$entity_types['field_config']->setFormClass('edit', 'Drupal\field_ui\Form\FieldConfigEditForm');
$entity_types['field_config']->setFormClass('delete', 'Drupal\field_ui\Form\FieldConfigDeleteForm');
$entity_types['field_config']->setListBuilderClass('Drupal\field_ui\FieldConfigListBuilder');
......
......@@ -69,8 +69,8 @@ protected function alterRoutes(RouteCollection $collection) {
$route = new Route(
"$path/fields/{field_config}",
array(
'_form' => '\Drupal\field_ui\Form\FieldEditForm',
'_title_callback' => '\Drupal\field_ui\Form\FieldEditForm::getTitle',
'_entity_form' => 'field_config.edit',
'_title_callback' => '\Drupal\field_ui\Form\FieldConfigEditForm::getTitle',
) + $defaults,
array('_entity_access' => 'field_config.update'),
$options
......
......@@ -201,7 +201,7 @@ function updateField() {
// Go to the field edit page.
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id);
$edit = array(
'field[settings][test_field_setting]' => $string,
'settings[test_field_setting]' => $string,
);
$this->assertText(t('Default value'), 'Default value heading is shown');
$this->drupalPostForm(NULL, $edit, t('Save settings'));
......@@ -284,7 +284,7 @@ protected function deleteField() {
// Delete the field.
$field_id = 'node.' . $this->contentType . '.' . $this->fieldName;
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id);
$this->drupalPostForm(NULL, array(), t('Delete field'));
$this->clickLink(t('Delete'));
$this->assertResponse(200);
}
......@@ -298,7 +298,8 @@ protected function addPersistentFieldStorage() {
// Delete all instances of the field.
foreach ($field_storage->getBundles() as $node_type) {
// Delete all the body field instances.
$this->drupalPostForm('admin/structure/types/manage/' . $node_type . '/fields/node.' . $node_type . '.' . $this->fieldName, array(), t('Delete field'));
$this->drupalGet('admin/structure/types/manage/' . $node_type . '/fields/node.' . $node_type . '.' . $this->fieldName);
$this->clickLink(t('Delete'));
$this->drupalPostForm(NULL, array(), t('Delete'));
}
// Check "Re-use existing field" appears.
......@@ -415,7 +416,7 @@ function testDefaultValue() {
$this->drupalGet($admin_path);
$edit = array(
'field[required]' => 1,
'required' => 1,
);
$this->drupalPostForm(NULL, $edit, t('Save settings'));
......@@ -650,7 +651,7 @@ function testHelpDescriptions() {
entity_get_form_display('node', 'article', 'default')->setComponent('field_image')->save();
$edit = array(
'field[description]' => '<strong>Test with an upload field.',
'description' => '<strong>Test with an upload field.',
);
$this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_image', $edit, t('Save settings'));
......@@ -660,7 +661,7 @@ function testHelpDescriptions() {
$this->assertText('From hook_field_widget_form_alter(): Default form is true.', 'Default value form in hook_field_widget_form_alter().');
$edit = array(
'field[description]' => '<em>Test with a non upload field.',
'description' => '<em>Test with a non upload field.',
);
$this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_tags', $edit, t('Save settings'));
......
......@@ -274,7 +274,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
'#weight' => 10,
'#states' => array(
'visible' => array(
':input[name="field[settings][alt_field]"]' => array('checked' => TRUE),
':input[name="settings[alt_field]"]' => array('checked' => TRUE),
),
),
);
......@@ -292,7 +292,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
'#weight' => 12,
'#states' => array(
'visible' => array(
':input[name="field[settings][title_field]"]' => array('checked' => TRUE),
':input[name="settings[title_field]"]' => array('checked' => TRUE),
),
),
);
......
......@@ -120,7 +120,7 @@ public function testDefaultImages() {
// Confirm the defaults are present on the article field edit form.
$this->drupalGet("admin/structure/types/manage/article/fields/$field_id");
$this->assertFieldByXpath(
'//input[@name="field[settings][default_image][uuid][fids]"]',
'//input[@name="settings[default_image][uuid][fids]"]',
$default_images['field']->id(),
format_string(
'Article image field field default equals expected file ID of @fid.',
......@@ -142,7 +142,7 @@ public function testDefaultImages() {
$field2_id = $field2->id();
$this->drupalGet("admin/structure/types/manage/page/fields/$field2_id");
$this->assertFieldByXpath(
'//input[@name="field[settings][default_image][uuid][fids]"]',
'//input[@name="settings[default_image][uuid][fids]"]',
$default_images['field2']->id(),
format_string(
'Page image field field default equals expected file ID of @fid.',
......@@ -220,7 +220,7 @@ public function testDefaultImages() {
// admin form.
$this->drupalGet("admin/structure/types/manage/article/fields/$field_id");
$this->assertFieldByXpath(
'//input[@name="field[settings][default_image][uuid][fids]"]',
'//input[@name="settings[default_image][uuid][fids]"]',
$default_images['field_new']->id(),
format_string(
'Updated article image field field default equals expected file ID of @fid.',
......@@ -264,7 +264,7 @@ public function testDefaultImages() {
// Confirm the article field field default has been removed.
$this->drupalGet("admin/structure/types/manage/article/fields/$field_id");
$this->assertFieldByXpath(
'//input[@name="field[settings][default_image][uuid][fids]"]',
'//input[@name="settings[default_image][uuid][fids]"]',
'',
'Updated article image field field default has been successfully removed.'
);
......@@ -293,7 +293,7 @@ public function testDefaultImages() {
);
$non_image = $this->drupalGetTestFiles('text');
$this->drupalPostForm(NULL, array('files[field_settings_default_image_uuid]' => drupal_realpath($non_image[0]->uri)), t("Upload"));
$this->drupalPostForm(NULL, array('files[settings_default_image_uuid]' => drupal_realpath($non_image[0]->uri)), t("Upload"));
$this->assertText(t('The specified file text-0.txt could not be uploaded. Only files with the following extensions are allowed: png gif jpg jpeg.'), 'Non-image file cannot be used as default image.');
// Confirm the default image is shown on the node form.
......
......@@ -222,10 +222,10 @@ function testImageFieldSettings() {
// Verify that the min/max resolution set on the field are properly
// extracted, and displayed, on the image field's configuration form.
$this->drupalGet('admin/structure/types/manage/article/fields/' . $field->id());
$this->assertFieldByName('field[settings][max_resolution][x]', '100', 'Expected max resolution X value of 100.');
$this->assertFieldByName('field[settings][max_resolution][y]', '100', 'Expected max resolution Y value of 100.');
$this->assertFieldByName('field[settings][min_resolution][x]', '10', 'Expected min resolution X value of 10.');
$this->assertFieldByName('field[settings][min_resolution][y]', '10', 'Expected min resolution Y value of 10.');
$this->assertFieldByName('settings[max_resolution][x]', '100', 'Expected max resolution X value of 100.');
$this->assertFieldByName('settings[max_resolution][y]', '100', 'Expected max resolution Y value of 100.');
$this->assertFieldByName('settings[min_resolution][x]', '10', 'Expected min resolution X value of 10.');
$this->assertFieldByName('settings[min_resolution][y]', '10', 'Expected min resolution Y value of 10.');
$this->drupalGet('node/add/article');
$this->assertText(t('50 KB limit.'), 'Image widget max file size is displayed on article form.');
......
......@@ -85,7 +85,7 @@ function testFieldUI() {
// external only links.
$label = $this->randomMachineName();
$field_name = Unicode::strtolower($label);
$field_edit = ['field[settings][link_type]' => LinkItemInterface::LINK_EXTERNAL];
$field_edit = ['settings[link_type]' => LinkItemInterface::LINK_EXTERNAL];
$this->fieldUIAddNewField($type_path, $field_name, $label, 'link', array(), $field_edit);
// Test the help text displays when link allows only external links.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment