diff --git a/core/includes/entity.inc b/core/includes/entity.inc index b65dfa3..ff67b4f 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -670,7 +670,7 @@ function entity_get_display($entity_type, $bundle, $view_mode) { $display = entity_create('entity_display', array( 'targetEntityType' => $entity_type, 'bundle' => $bundle, - 'displayMode' => $view_mode, + 'mode' => $view_mode, )); } @@ -712,7 +712,7 @@ function entity_get_render_display(EntityInterface $entity, $view_mode) { $render_view_mode = !empty($view_mode_settings[$view_mode]['custom_settings']) ? $view_mode : 'default'; $display = entity_get_display($entity_type, $bundle, $render_view_mode); - $display->originalDisplayMode = $view_mode; + $display->originalMode = $view_mode; return $display; } @@ -770,7 +770,7 @@ function entity_get_form_display($entity_type, $bundle, $form_mode = 'default') $entity_form_display = entity_create('entity_form_display', array( 'targetEntityType' => $entity_type, 'bundle' => $bundle, - 'displayMode' => $form_mode, + 'mode' => $form_mode, )); } diff --git a/core/modules/entity/entity.install b/core/modules/entity/entity.install index cd28c73..af2aba1 100644 --- a/core/modules/entity/entity.install +++ b/core/modules/entity/entity.install @@ -37,7 +37,7 @@ function _update_8000_entity_get_display($entity_type, $bundle, $view_mode) { 'uuid' => $uuid->generate(), 'targetEntityType' => $entity_type, 'bundle' => $bundle, - 'displayMode' => $view_mode, + 'mode' => $view_mode, 'content' => array(), ); foreach ($properties as $key => $value) { @@ -76,7 +76,7 @@ function _update_8000_entity_get_form_display($entity_type, $bundle, $form_mode) 'uuid' => $uuid->generate(), 'targetEntityType' => $entity_type, 'bundle' => $bundle, - 'displayMode' => $form_mode, + 'mode' => $form_mode, 'content' => array(), ); foreach ($properties as $key => $value) { diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module index aa71c1d..d805b52 100644 --- a/core/modules/entity/entity.module +++ b/core/modules/entity/entity.module @@ -22,7 +22,7 @@ function entity_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_ne foreach ($ids as $id) { $id = ConfigStorageController::getIDFromConfigName($id, $entity_info['config_prefix']); $form_display = entity_load('entity_form_display', $id); - $new_id = $entity_type . '.' . $bundle_new . '.' . $form_display->displayMode; + $new_id = $entity_type . '.' . $bundle_new . '.' . $form_display->mode; $form_display->id = $new_id; $form_display->bundle = $bundle_new; $form_display->save(); diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php index 1130dd1..d337457 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php @@ -48,7 +48,7 @@ * * @var string */ - public $displayMode; + public $mode; /** * List of component display options, keyed by component name. @@ -63,7 +63,7 @@ * * @var string */ - public $originalDisplayMode; + public $originalMode; /** * The plugin objects used for this display, keyed by field name. @@ -94,7 +94,7 @@ public function __construct(array $values, $entity_type) { // currently produces invalid entities with a NULL bundle in some cases. // Add the validity checks back when http://drupal.org/node/1856556 is // fixed. - // if (!isset($values['targetEntityType']) || !isset($values['bundle']) || !isset($values['displayMode'])) { + // if (!isset($values['targetEntityType']) || !isset($values['bundle']) || !isset($values['mode'])) { // throw new \InvalidArgumentException('Missing required properties for an EntityDisplay entity.'); // } @@ -108,14 +108,14 @@ public function __construct(array $values, $entity_type) { parent::__construct($values, $entity_type); - $this->originalDisplayMode = $this->displayMode; + $this->originalMode = $this->mode; } /** * Overrides \Drupal\Core\Entity\Entity::id(). */ public function id() { - return $this->targetEntityType . '.' . $this->bundle . '.' . $this->displayMode; + return $this->targetEntityType . '.' . $this->bundle . '.' . $this->mode; } /** @@ -138,7 +138,7 @@ public function getExportProperties() { 'uuid', 'targetEntityType', 'bundle', - 'displayMode', + 'mode', 'content', ); $properties = array(); @@ -149,20 +149,20 @@ public function getExportProperties() { } /** - * Creates a duplicate object on a different display mode. + * Creates a duplicate object on a different form or view mode. * * The new object necessarily has the same $targetEntityType and $bundle - * properties than the original one. + * properties as the original one. * - * @param $display_mode - * The display mode for the new object. + * @param string $mode + * The form or view mode for the new object. * * @return \Drupal\entity\EntityDisplayBase * The new object. */ - public function createCopy($display_mode) { + public function createCopy($mode) { $display = $this->createDuplicate(); - $display->displayMode = $display->originalDisplayMode = $display_mode; + $display->mode = $display->originalMode = $mode; return $display; } @@ -236,8 +236,8 @@ public function getComponent($name) { * @param array $options * The display options. * - * @return \Drupal\entity\Plugin\Core\Entity\EntityDisplay - * The EntityDisplay object. + * @return \Drupal\entity\EntityDisplayBase + * The EntityDisplayBase object. */ public function setComponent($name, array $options = array()) { // If no weight specified, make sure the field sinks at the bottom. @@ -271,8 +271,8 @@ public function setComponent($name, array $options = array()) { * @param string $name * The name of the component. * - * @return \Drupal\entity\Plugin\Core\Entity\EntityDisplay - * The EntityDisplay object. + * @return \Drupal\entity\EntityDisplayBase + * The EntityDisplayBase object. */ public function removeComponent($name) { $extra_fields = field_info_extra_fields($this->targetEntityType, $this->bundle, $this->displayContext); @@ -311,7 +311,7 @@ public function getHighestWeight() { } // Let other modules feedback about their own additions. - $weights = array_merge($weights, module_invoke_all('field_info_max_weight', $this->targetEntityType, $this->bundle, $this->displayContext, $this->displayMode)); + $weights = array_merge($weights, module_invoke_all('field_info_max_weight', $this->targetEntityType, $this->bundle, $this->displayContext, $this->mode)); return $weights ? max($weights) : NULL; } diff --git a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php index 9d59852..3341cec 100644 --- a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php +++ b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php @@ -7,7 +7,6 @@ namespace Drupal\entity\Plugin\Core\Entity; -use Drupal; use Drupal\Component\Annotation\Plugin; use Drupal\Core\Annotation\Translation; use Drupal\entity\EntityDisplayBase; @@ -34,7 +33,7 @@ class EntityDisplay extends EntityDisplayBase { * Overrides \Drupal\entity\EntityDisplayBase::__construct(). */ public function __construct(array $values, $entity_type) { - $this->pluginManager = Drupal::service('plugin.manager.field.formatter'); + $this->pluginManager = \Drupal::service('plugin.manager.field.formatter'); $this->displayContext = 'display'; parent::__construct($values, $entity_type); @@ -60,7 +59,7 @@ public function getFormatter($field_name) { $instance = field_info_instance($this->targetEntityType, $field_name, $this->bundle); $formatter = $this->pluginManager->getInstance(array( 'instance' => $instance, - 'view_mode' => $this->originalDisplayMode, + 'view_mode' => $this->originalMode, // No need to prepare, defaults have been merged in setComponent(). 'prepare' => FALSE, 'configuration' => $configuration diff --git a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityFormDisplay.php b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityFormDisplay.php index eb9a280..a3b2903 100644 --- a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityFormDisplay.php +++ b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityFormDisplay.php @@ -7,7 +7,6 @@ namespace Drupal\entity\Plugin\Core\Entity; -use Drupal; use Drupal\Component\Annotation\Plugin; use Drupal\Core\Annotation\Translation; use Drupal\entity\EntityDisplayBase; @@ -34,7 +33,7 @@ class EntityFormDisplay extends EntityDisplayBase { * Overrides \Drupal\entity\EntityDisplayBase::__construct(). */ public function __construct(array $values, $entity_type) { - $this->pluginManager = Drupal::service('plugin.manager.field.widget'); + $this->pluginManager = \Drupal::service('plugin.manager.field.widget'); $this->displayContext = 'form'; parent::__construct($values, $entity_type); @@ -69,7 +68,7 @@ public function getWidget($field_name) { $widget = $this->pluginManager->getInstance(array( 'instance' => $instance, - 'form_mode' => $this->originalDisplayMode, + 'form_mode' => $this->originalMode, // No need to prepare, defaults have been merged in setComponent(). 'prepare' => FALSE, 'configuration' => $configuration diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php index 7ea876a..f5a35af 100644 --- a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php +++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php @@ -37,7 +37,7 @@ public function testEntityDisplayCRUD() { $display = entity_create('entity_display', array( 'targetEntityType' => 'entity_test', 'bundle' => 'entity_test', - 'displayMode' => 'default', + 'mode' => 'default', )); $expected = array(); @@ -82,7 +82,7 @@ public function testEntityDisplayCRUD() { $new_display = entity_load('entity_display', $new_display->id()); $this->assertEqual($new_display->targetEntityType, $display->targetEntityType); $this->assertEqual($new_display->bundle, $display->bundle); - $this->assertEqual($new_display->displayMode, 'other_view_mode'); + $this->assertEqual($new_display->mode, 'other_view_mode'); $this->assertEqual($new_display->getComponents(), $display->getComponents()); } @@ -113,7 +113,7 @@ public function testExtraFieldComponent() { $display = entity_create('entity_display', array( 'targetEntityType' => 'entity_test', 'bundle' => 'entity_test', - 'displayMode' => 'default', + 'mode' => 'default', )); // Check that the default visibility taken into account for extra fields @@ -137,7 +137,7 @@ public function testFieldComponent() { $display = entity_create('entity_display', array( 'targetEntityType' => 'entity_test', 'bundle' => 'entity_test', - 'displayMode' => 'default', + 'mode' => 'default', )); // Create a field and an instance. diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityFormDisplayTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityFormDisplayTest.php new file mode 100644 index 0000000..9d8accb --- /dev/null +++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityFormDisplayTest.php @@ -0,0 +1,122 @@ + 'Entity form display configuration entities', + 'description' => 'Tests the entity form display configuration entities.', + 'group' => 'Entity API', + ); + } + + protected function setUp() { + parent::setUp(); + + $this->installSchema('field', array('field_config', 'field_config_instance')); + } + + /** + * Tests entity_get_form_display(). + */ + public function testEntityGetFromDisplay() { + // Check that entity_get_form_display() returns a fresh object when no + // configuration entry exists. + $form_display = entity_get_form_display('entity_test', 'entity_test', 'default'); + $this->assertTrue($form_display->isNew()); + + // Add some components and save the display. + $form_display->setComponent('component_1', array('weight' => 10)) + ->save(); + + // Check that entity_get_form_display() returns the correct object. + $form_display = entity_get_form_display('entity_test', 'entity_test', 'default'); + $this->assertFalse($form_display->isNew()); + $this->assertEqual($form_display->id, 'entity_test.entity_test.default'); + $this->assertEqual($form_display->getComponent('component_1'), array('weight' => 10)); + } + + /** + * Tests the behavior of a field component within an EntityDisplay object. + */ + public function testFieldComponent() { + $this->enableModules(array('field_sql_storage', 'field_test')); + + $form_display = entity_create('entity_form_display', array( + 'targetEntityType' => 'entity_test', + 'bundle' => 'entity_test', + 'mode' => 'default', + )); + + // Create a field and an instance. + $field = array( + 'field_name' => 'test_field', + 'type' => 'test_field' + ); + field_create_field($field); + $instance = array( + 'field_name' => $field['field_name'], + 'entity_type' => 'entity_test', + 'bundle' => 'entity_test', + ); + field_create_instance($instance); + + // Check that providing no options results in default values being used. + $form_display->setComponent($field['field_name']); + $field_type_info = field_info_field_types($field['type']); + $default_widget = $field_type_info['default_widget']; + $default_settings = field_info_widget_settings($default_widget); + $expected = array( + 'weight' => 0, + 'type' => $default_widget, + 'settings' => $default_settings, + ); + $this->assertEqual($form_display->getComponent($field['field_name']), $expected); + + // Check that the getWidget() method returns the correct widget plugin. + $widget = $form_display->getWidget($field['field_name']); + $this->assertEqual($widget->getPluginId(), $default_widget); + $this->assertEqual($widget->getSettings(), $default_settings); + + // Check that the widget is statically persisted, by assigning an + // arbitrary property and reading it back. + $random_value = $this->randomString(); + $widget->randomValue = $random_value; + $widget = $form_display->getWidget($field['field_name']); + $this->assertEqual($widget->randomValue, $random_value ); + + // Check that changing the definition creates a new widget. + $form_display->setComponent($field['field_name'], array( + 'type' => 'field_test_multiple', + )); + $widget = $form_display->getWidget($field['field_name']); + $this->assertEqual($widget->getPluginId(), 'test_field_widget'); + $this->assertFalse(isset($widget->randomValue)); + + // Check that specifying an unknown widget (e.g. case of a disabled module) + // gets stored as is in the display, but results in the default widget being + // used. + $form_display->setComponent($field['field_name'], array( + 'type' => 'unknown_widget', + )); + $options = $form_display->getComponent($field['field_name']); + $this->assertEqual($options['type'], 'unknown_widget'); + $widget = $form_display->getWidget($field['field_name']); + $this->assertEqual($widget->getPluginId(), $default_widget); + } + +} diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index d50fc8a..4919bc7 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -1865,38 +1865,6 @@ function hook_field_info_max_weight($entity_type, $bundle, $context, $context_mo } /** - * Alters the widget properties of a field instance on a given entity type - * before it gets displayed. - * - * Modules can implement hook_field_widget_properties_ENTITY_TYPE_alter() to - * alter the widget properties for fields on a specific entity type, rather than - * implementing hook_field_widget_properties_alter(). - * - * This hook is called once per field per displayed widget entity. If the result - * of the hook involves reading from the database, it is highly recommended to - * statically cache the information. - * - * @param array $widget_properties - * The instance's widget properties. - * @param array $context - * An associative array containing: - * - entity_type: The entity type, e.g., 'node' or 'user'. - * - bundle: The bundle, e.g., 'page' or 'article'. - * - field: The field that the widget belongs to. - * - instance: The instance of the field. - * - * @see hook_field_widget_properties_alter() - */ -function hook_field_widget_properties_ENTITY_TYPE_alter(array &$widget_properties, array $context) { - // Change a widget's type according to the time of day. - $field = $context['field']; - if ($field['field_name'] == 'field_foo') { - $time = date('H'); - $widget_properties['type'] = $time < 12 ? 'widget_am' : 'widget_pm'; - } -} - -/** * @} End of "addtogroup field_storage". */ diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index 20389e5..1c54377 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -1440,7 +1440,7 @@ function field_attach_view(EntityInterface $entity, EntityDisplay $display, $lan $entity = $entity->getOriginalEntity(); // Let other modules alter the renderable array. - $view_mode = $display->originalDisplayMode; + $view_mode = $display->originalMode; $context = array( 'entity' => $entity, 'view_mode' => $view_mode, diff --git a/core/modules/field/lib/Drupal/field/Plugin/field/widget/LegacyWidget.php b/core/modules/field/lib/Drupal/field/Plugin/field/widget/LegacyWidget.php index f99023a..a03cb5e 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/field/widget/LegacyWidget.php +++ b/core/modules/field/lib/Drupal/field/Plugin/field/widget/LegacyWidget.php @@ -47,7 +47,13 @@ public function formElement(array $items, $delta, array $element, $langcode, arr $function = $definition['module'] . '_field_widget_form'; if (function_exists($function)) { + // hook_field_widget_form() implementations read widget properties directly + // from $instance. Put the actual properties we use here, which might have + // been altered by hook_field_widget_property(). $instance = clone $this->instance; + $instance['widget']['type'] = $this->getPluginId(); + $instance['widget']['settings'] = $this->getSettings(); + return $function($form, $form_state, $this->field, $instance, $langcode, $items, $delta, $element); } return array(); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php index 85c3065..031aa94 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php @@ -166,10 +166,6 @@ function testInstancePrepare() { ); field_create_instance($instance_definition); - $entity_form_display = entity_get_form_display('test_entity', 'test_bundle') - ->setComponent($field_definition['field_name']) - ->save(); - // Simulate a stored instance definition missing various settings (e.g. a // third-party module adding instance or widget settings has been enabled, // but existing instances do not know the new settings). @@ -190,12 +186,6 @@ function testInstancePrepare() { // Check that all expected instance settings are in place. $field_type = field_info_field_types($field_definition['type']); $this->assertIdentical($instance['settings'], $field_type['instance_settings'] , 'All expected instance settings are present.'); - - // Check that the default widget is used and expected settings are in place. - $widget = entity_get_form_display('test_entity', 'test_bundle')->getWidget($instance_definition['field_name']); - $this->assertIdentical($widget->getPluginId(), $field_type['default_widget'], 'Unavailable widget replaced with default widget.'); - $widget_type = $widget->getDefinition(); - $this->assertIdentical($widget->getSettings(), $widget_type['settings'] , 'All expected widget settings are present.'); } /** diff --git a/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php b/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php index 8c74099..f804753 100644 --- a/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php +++ b/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php @@ -30,7 +30,7 @@ * * @var array */ - public static $modules = array('entity_test', 'entity_reference', 'field', 'field_sql_storage', 'hal', 'language', 'rest', 'serialization', 'system', 'text', 'user', 'entity'); + public static $modules = array('entity', 'entity_test', 'entity_reference', 'field', 'field_sql_storage', 'hal', 'language', 'rest', 'serialization', 'system', 'text', 'user'); /** * The mock serializer. diff --git a/core/modules/link/link.module b/core/modules/link/link.module index 57e9687..57d744c 100644 --- a/core/modules/link/link.module +++ b/core/modules/link/link.module @@ -112,7 +112,7 @@ function link_field_widget_info() { * Implements hook_field_widget_settings_form(). */ function link_field_widget_settings_form($field, $instance) { - $widget = entity_get_form_display($instance['entity_type'], $instance['bundle'], 'default')->getComponent($instance['field_name']); + $widget = $instance['widget']; $settings = $widget['settings']; $form['placeholder_url'] = array( @@ -141,8 +141,7 @@ function link_field_widget_settings_form($field, $instance) { */ function link_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { $settings = $instance['settings']; - $widget = entity_get_form_display($instance['entity_type'], $instance['bundle'], 'default')->getComponent($instance['field_name']); - $widget_settings = $widget['settings']; + $widget_settings = $instance['widget']['settings']; $element['url'] = array( '#type' => 'url', diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php index c61deaa..0ed5426 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php @@ -262,14 +262,7 @@ protected function createOptionsField($type) { ); field_create_instance($instance); - // Grab the default widget for the field type. - $field_type_definition = field_info_field_types($field['type']); - $plugin_id = $field_type_definition['default_widget']; - entity_get_form_display('node', $this->type, 'default') - ->setComponent($this->field_name, array( - 'type' => $plugin_id, - )) - ->save(); + entity_get_form_display('node', $this->type, 'default')->setComponent($this->field_name)->save(); $this->admin_path = 'admin/structure/types/manage/' . $this->type . '/fields/' . $this->field_name . '/field-settings'; } diff --git a/core/modules/options/options.module b/core/modules/options/options.module index 96b8ec3..793b07e 100644 --- a/core/modules/options/options.module +++ b/core/modules/options/options.module @@ -151,11 +151,10 @@ function options_field_settings_form($field, $instance, $has_data) { } // Alter the description for allowed values depending on the widget type. - $widget = entity_get_form_display($instance['entity_type'], $instance['bundle'], 'default')->getComponent($instance['field_name']); - if ($widget['type'] == 'options_onoff') { + if ($instance['widget']['type'] == 'options_onoff') { $form['allowed_values']['#description'] .= '

' . t("For a 'single on/off checkbox' widget, define the 'off' value first, then the 'on' value in the Allowed values section. Note that the checkbox will be labeled with the label of the 'on' value.") . '

'; } - elseif ($widget['type'] == 'options_buttons') { + elseif ($instance['widget']['type'] == 'options_buttons') { $form['allowed_values']['#description'] .= '

' . t("The 'checkboxes/radio buttons' widget will display checkboxes if the Number of values option is greater than 1 for this field, otherwise radios will be displayed.") . '

'; } $form['allowed_values']['#description'] .= '

' . t('Allowed HTML tags in labels: @tags', array('@tags' => _field_filter_xss_display_allowed_tags())) . '

'; @@ -480,8 +479,7 @@ function options_field_widget_form(&$form, &$form_state, $field, $instance, $lan // reuse those widgets. $value_key = key($field['columns']); - $widget = entity_get_form_display($instance['entity_type'], $instance['bundle'], 'default')->getComponent($instance['field_name']); - $type = str_replace('options_', '', $widget['type']); + $type = str_replace('options_', '', $instance['widget']['type']); $multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED; $required = $element['#required']; $has_value = isset($items[0][$value_key]); @@ -542,7 +540,7 @@ function options_field_widget_form(&$form, &$form_state, $field, $instance, $lan // Override the title from the incoming $element. $element['#title'] = isset($options[$on_value]) ? $options[$on_value] : ''; - if ($widget['settings']['display_label']) { + if ($instance['widget']['settings']['display_label']) { $element['#title'] = $instance['label']; } break; @@ -562,12 +560,11 @@ function options_field_widget_form(&$form, &$form_state, $field, $instance, $lan */ function options_field_widget_settings_form($field, $instance) { $form = array(); - $widget = entity_get_form_display($instance['entity_type'], $instance['bundle'], 'default')->getComponent($instance['field_name']); - if ($widget['type'] == 'options_onoff') { + if ($instance['widget']['type'] == 'options_onoff') { $form['display_label'] = array( '#type' => 'checkbox', '#title' => t('Use field label instead of the "On value" as label'), - '#default_value' => $widget['settings']['display_label'], + '#default_value' => $instance['widget']['settings']['display_label'], '#weight' => -1, ); } @@ -854,8 +851,7 @@ function theme_options_none($variables) { $option = $variables['option']; $output = ''; - $widget = entity_get_form_display($instance['entity_type'], $instance['bundle'], 'default')->getComponent($instance['field_name']); - switch ($widget['type']) { + switch ($instance['widget']['type']) { case 'options_buttons': $output = t('N/A'); break; diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php index c9b84e5..b6c226d 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php @@ -232,7 +232,7 @@ function testEnableModulesFixedList() { $display = entity_create('entity_display', array( 'targetEntityType' => 'entity_test', 'bundle' => 'entity_test', - 'displayMode' => 'default', + 'mode' => 'default', )); $field = array( 'field_name' => 'test_field', diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php index e021356..fcf188d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php @@ -19,7 +19,7 @@ * * @var array */ - public static $modules = array('user', 'system', 'field', 'text', 'field_sql_storage', 'entity', 'entity_test'); + public static $modules = array('entity', 'user', 'system', 'field', 'text', 'field_sql_storage', 'entity_test'); public function setUp() { parent::setUp(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php index ea0ddc3..d357431 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php @@ -19,7 +19,7 @@ class FieldAccessTest extends DrupalUnitTestBase { * * @var array */ - public static $modules = array('entity_test', 'field', 'field_sql_storage', 'system', 'text', 'user', 'entity'); + public static $modules = array('entity', 'entity_test', 'field', 'field_sql_storage', 'system', 'text', 'user'); /** * Holds the currently active global user ID that initiated the test run. diff --git a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php index d702836..e12553f 100644 --- a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php +++ b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php @@ -64,14 +64,6 @@ function testTextFieldValidation() { 'bundle' => 'test_bundle', ); field_create_instance($this->instance); - entity_get_form_display('test_entity', 'test_bundle', 'default') - ->setComponent($this->field['field_name'], array( - 'type' => 'text_textfield', - )) - ->save(); -// entity_get_display('test_entity', 'test_bundle', 'default') -// ->setComponent($this->field['field_name']) -// ->save(); // Test valid and invalid values with field_attach_validate(). $entity = field_test_create_entity();