';
+ // We can set the 'rows_order' element, needed by theme_field_ui_table(),
+ // here instead of a #pre_render callback because this form doesn't have the
+ // tabledrag behavior anymore.
+ foreach (element_children($table) as $name) {
+ $table['#regions']['content']['rows_order'][] = $name;
+ }
- // This key is used to store the current updated field.
- $form_state += array(
- 'formatter_settings_edit' => NULL,
- );
+ $form['fields'] = $table;
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
- $form['#attached']['library'][] = array('field_ui', 'drupal.field_ui');
-
- // Add settings for the update selects behavior.
- $js_fields = array();
- foreach ($existing_fields as $field_name => $info) {
- $js_fields[$field_name] = array('label' => $info['label'], 'type' => $info['type'], 'widget' => $info['widget_type']);
- }
-
- $form['#attached']['js'][] = array(
- 'type' => 'setting',
- 'data' => array('fields' => $js_fields, 'fieldWidgetTypes' => $widget_options),
- );
-
- // Add tabledrag behavior.
- $form['#attached']['drupal_add_tabledrag'][] = array('field-overview', 'order', 'sibling', 'field-weight');
- $form['#attached']['drupal_add_tabledrag'][] = array('field-overview', 'match', 'parent', 'field-parent', 'field-parent', 'field-name');
-
return $form;
}
/**
- * Implements \Drupal\Core\Form\FormInterface::validateForm().
+ * {@inheritdoc}
*/
public function validateForm(array &$form, array &$form_state) {
$this->validateAddNew($form, $form_state);
@@ -493,7 +266,7 @@ protected function validateAddNew(array $form, array &$form_state) {
$field = $form_state['values']['fields']['_add_new_field'];
// Validate if any information was provided in the 'add new field' row.
- if (array_filter(array($field['label'], $field['field_name'], $field['type'], $field['widget_type']))) {
+ if (array_filter(array($field['label'], $field['field_name'], $field['type']))) {
// Missing label.
if (!$field['label']) {
form_set_error('fields][_add_new_field][label', t('Add new field: you need to provide a label.'));
@@ -516,18 +289,6 @@ protected function validateAddNew(array $form, array &$form_state) {
if (!$field['type']) {
form_set_error('fields][_add_new_field][type', t('Add new field: you need to select a field type.'));
}
-
- // Missing widget type.
- if (!$field['widget_type']) {
- form_set_error('fields][_add_new_field][widget_type', t('Add new field: you need to select a widget.'));
- }
- // Wrong widget type.
- elseif ($field['type']) {
- $widget_types = $this->widgetManager->getOptions($field['type']);
- if (!isset($widget_types[$field['widget_type']])) {
- form_set_error('fields][_add_new_field][widget_type', t('Add new field: invalid widget.'));
- }
- }
}
}
@@ -549,7 +310,7 @@ protected function validateAddExisting(array $form, array &$form_state) {
// Validate if any information was provided in the
// 're-use existing field' row.
- if (array_filter(array($field['label'], $field['field_name'], $field['widget_type']))) {
+ if (array_filter(array($field['label'], $field['field_name']))) {
// Missing label.
if (!$field['label']) {
form_set_error('fields][_add_existing_field][label', t('Re-use existing field: you need to provide a label.'));
@@ -559,18 +320,6 @@ protected function validateAddExisting(array $form, array &$form_state) {
if (!$field['field_name']) {
form_set_error('fields][_add_existing_field][field_name', t('Re-use existing field: you need to select a field.'));
}
-
- // Missing widget type.
- if (!$field['widget_type']) {
- form_set_error('fields][_add_existing_field][widget_type', t('Re-use existing field: you need to select a widget.'));
- }
- // Wrong widget type.
- elseif ($field['field_name'] && ($existing_field = field_info_field($field['field_name']))) {
- $widget_types = $this->widgetManager->getOptions($existing_field['type']);
- if (!isset($widget_types[$field['widget_type']])) {
- form_set_error('fields][_add_existing_field][widget_type', t('Re-use existing field: invalid widget.'));
- }
- }
}
}
}
@@ -580,26 +329,6 @@ protected function validateAddExisting(array $form, array &$form_state) {
*/
public function submitForm(array &$form, array &$form_state) {
$form_values = $form_state['values']['fields'];
- $entity_form_display = entity_get_form_display($this->entity_type, $this->bundle, $this->mode);
-
- // Collect data for 'regular' fields.
- foreach ($form['#fields'] as $field_name) {
- $options = $entity_form_display->getComponent($field_name);
- $options['weight'] = $form_values[$field_name]['weight'];
-
- $entity_form_display->setComponent($field_name, $options);
- }
-
- // Collect data for 'extra' fields.
- foreach ($form['#extra'] as $field_name) {
- $entity_form_display->setComponent($field_name, array(
- 'weight' => $form_values[$field_name]['weight'],
- ));
- }
-
- // Save the form display.
- $entity_form_display->save();
-
$destinations = array();
// Create new field.
@@ -625,12 +354,10 @@ public function submitForm(array &$form, array &$form_state) {
$new_instance->save();
// Make sure the field is displayed in the 'default' form mode (using
- // the configured widget and default settings).
+ // default widget and settings). It stays hidden for other form modes
+ // until it is explicitly configured.
entity_get_form_display($this->entity_type, $this->bundle, 'default')
- ->setComponent($field['field_name'], array(
- 'type' => $values['widget_type'],
- 'weight' => $values['weight'],
- ))
+ ->setComponent($field['field_name'])
->save();
// Make sure the field is displayed in the 'default' view mode (using
@@ -673,12 +400,10 @@ public function submitForm(array &$form, array &$form_state) {
$new_instance->save();
// Make sure the field is displayed in the 'default' form mode (using
- // the configured widget and default settings).
+ // default widget and settings). It stays hidden for other form modes
+ // until it is explicitly configured.
entity_get_form_display($this->entity_type, $this->bundle, 'default')
- ->setComponent($field['field_name'], array(
- 'type' => $values['widget_type'],
- 'weight' => $values['weight'],
- ))
+ ->setComponent($field['field_name'])
->save();
// Make sure the field is displayed in the 'default' view mode (using
@@ -713,27 +438,6 @@ public function submitForm(array &$form, array &$form_state) {
}
/**
- * Returns the region to which a row in the display overview belongs.
- *
- * @param array $row
- * The row element.
- *
- * @return string|null
- * The region name this row belongs to.
- */
- public function getRowRegion($row) {
- switch ($row['#row_type']) {
- case 'field':
- case 'extra_field':
- return 'content';
- case 'add_new_field':
- // If no input in 'label', assume the row has not been dragged out of the
- // 'add new' section.
- return (!empty($row['label']['#value']) ? 'content' : 'hidden');
- }
- }
-
- /**
* Returns an array of existing fields to be added to a bundle.
*
* @return array
@@ -759,13 +463,11 @@ protected function getExistingFieldOptions() {
&& !field_info_instance($this->entity_type, $field['field_name'], $this->bundle)
&& (empty($field['entity_types']) || in_array($this->entity_type, $field['entity_types']))
&& empty($field_types[$field['type']]['no_ui'])) {
- $widget = entity_get_form_display($instance['entity_type'], $instance['bundle'], 'default')->getComponent($instance['field_name']);
$info[$instance['field_name']] = array(
'type' => $field['type'],
'type_label' => $field_types[$field['type']]['label'],
'field' => $field['field_name'],
'label' => $instance['label'],
- 'widget_type' => $widget['type'],
);
}
}
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php
index 16ab117..26264ac 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php
@@ -103,11 +103,6 @@ public function buildForm(array $form, array &$form_state, FieldInstanceInterfac
$form['instance']['settings'] = $this->getFieldItem($form['#entity'], $this->instance['field_name'])->instanceSettingsForm($form, $form_state);
$form['instance']['settings']['#weight'] = 10;
- // Add widget settings for the widget type.
- $additions = $entity_form_display->getWidget($this->instance->getField()->id)->settingsForm($form, $form_state);
- $form['instance']['widget']['settings'] = $additions ?: array('#type' => 'value', '#value' => array());
- $form['instance']['widget']['#weight'] = 20;
-
// Add handling for default value if not provided by any other module.
if (field_behaviors_widget('default_value', $this->instance) == FIELD_BEHAVIOR_DEFAULT && empty($this->instance['default_value_function'])) {
$form['instance']['default_value_widget'] = $this->getDefaultValueWidget($field, $form, $form_state);
@@ -141,7 +136,7 @@ public function validateForm(array &$form, array &$form_state) {
// Extract the 'default value'.
$items = array();
- $entity_form_display->getWidget($this->instance->getField()->id)->extractFormValues($entity, Language::LANGCODE_NOT_SPECIFIED, $items, $element, $form_state);
+ $entity_form_display->getRenderer($this->instance->getField()->id)->extractFormValues($entity, Language::LANGCODE_NOT_SPECIFIED, $items, $element, $form_state);
// @todo Simplify when all entity types are converted to EntityNG.
if ($entity instanceof EntityNG) {
@@ -165,7 +160,7 @@ public function validateForm(array &$form, array &$form_state) {
field_form_set_state($element['#parents'], $field_name, Language::LANGCODE_NOT_SPECIFIED, $form_state, $field_state);
// Assign reported errors to the correct form element.
- $entity_form_display->getWidget($this->instance->getField()->id)->flagErrors($entity, Language::LANGCODE_NOT_SPECIFIED, $items, $element, $form_state);
+ $entity_form_display->getRenderer($this->instance->getField()->id)->flagErrors($entity, Language::LANGCODE_NOT_SPECIFIED, $items, $element, $form_state);
}
}
}
@@ -183,17 +178,11 @@ public function submitForm(array &$form, array &$form_state) {
// Extract field values.
$items = array();
- $entity_form_display->getWidget($this->instance->getField()->id)->extractFormValues($entity, Language::LANGCODE_NOT_SPECIFIED, $items, $element, $form_state);
+ $entity_form_display->getRenderer($this->instance->getField()->id)->extractFormValues($entity, Language::LANGCODE_NOT_SPECIFIED, $items, $element, $form_state);
$this->instance['default_value'] = $items ? $items : NULL;
}
- // Handle widget settings.
- $options = $entity_form_display->getComponent($this->instance->getField()->id);
- $options['settings'] = $form_state['values']['instance']['widget']['settings'];
- $entity_form_display->setComponent($this->instance->getField()->id, $options)->save();
- unset($form_state['values']['instance']['widget']);
-
// Merge incoming values into the instance.
foreach ($form_state['values']['instance'] as $key => $value) {
$this->instance[$key] = $value;
@@ -202,10 +191,6 @@ public function submitForm(array &$form, array &$form_state) {
drupal_set_message(t('Saved %label configuration.', array('%label' => $this->instance->label())));
- if ($this->instance['required'] && empty($this->instance['default_value']) && empty($this->instance['default_value_function']) && $this->instance['widget']['type'] == 'field_hidden') {
- drupal_set_message(t('Field %label is required and uses the "hidden" widget. You might want to configure a default value.', array('%label' => $this->instance['label'])), 'warning');
- }
-
$form_state['redirect'] = $this->getNextDestination();
}
@@ -246,7 +231,9 @@ protected function getDefaultValueWidget($field, array &$form, &$form_state) {
// Adjust the instance definition to use the default widget of this field type
// instead of the hidden widget.
- if ($this->instance['widget']['type'] == 'field_hidden') {
+ // @todo Clean this up since we don't have $this->instance['widget'] anymore.
+ // see https://drupal.org/node/2028759
+ if ($this->instance['widget']['type'] == 'hidden') {
$field_type = field_info_field_types($field['type']);
$default_widget = $this->widgetManager->getDefinition($field_type['default_widget']);
@@ -263,7 +250,7 @@ protected function getDefaultValueWidget($field, array &$form, &$form_state) {
if (!empty($this->instance['default_value'])) {
$items = (array) $this->instance['default_value'];
}
- $element += $entity_form_display->getWidget($this->instance->getField()->id)->form($entity, Language::LANGCODE_NOT_SPECIFIED, $items, $element, $form_state);
+ $element += $entity_form_display->getRenderer($this->instance->getField()->id)->form($entity, Language::LANGCODE_NOT_SPECIFIED, $items, $element, $form_state);
return $element;
}
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldWidgetTypeForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldWidgetTypeForm.php
deleted file mode 100644
index 4f44947..0000000
--- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldWidgetTypeForm.php
+++ /dev/null
@@ -1,99 +0,0 @@
-instance['label']);
-
- $bundle = $this->instance['bundle'];
- $entity_type = $this->instance['entity_type'];
- $field_name = $this->instance['field_name'];
-
- $entity_form_display = entity_get_form_display($entity_type, $bundle, 'default');
- $field = $this->instance->getField();
- $bundles = entity_get_bundles();
- $bundle_label = $bundles[$entity_type][$bundle]['label'];
-
- $form = array(
- '#bundle' => $bundle,
- '#entity_type' => $entity_type,
- '#field_name' => $field_name,
- '#instance' => $this->instance,
- );
-
- $form['widget_type'] = array(
- '#type' => 'select',
- '#title' => t('Widget type'),
- '#required' => TRUE,
- '#options' => $this->widgetManager->getOptions($field['type']),
- '#default_value' => $entity_form_display->getWidget($field_name)->getPluginId(),
- '#description' => t('The type of form element you would like to present to the user when creating this field in the %type type.', array('%type' => $bundle_label)),
- );
-
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Continue'));
-
- return $form;
- }
-
- /**
- * {@inheritdoc}
- */
- public function validateForm(array &$form, array &$form_state) {
- }
-
- /**
- * {@inheritdoc}
- */
- public function submitForm(array &$form, array &$form_state) {
- $form_values = $form_state['values'];
- $bundle = $form['#bundle'];
- $entity_type = $form['#entity_type'];
- $field_name = $form['#field_name'];
- $instance = $form['#instance'];
-
- $entity_form_display = entity_get_form_display($entity_type, $bundle, 'default')
- ->setComponent($field_name, array(
- 'type' => $form_values['widget_type'],
- ));
-
- try {
- $entity_form_display->save();
- drupal_set_message(t('Changed the widget for field %label.', array('%label' => $instance['label'])));
-
- if ($instance['required'] && empty($instance['default_value']) && empty($instance['default_value_function']) && $instance['widget']['type'] == 'field_hidden') {
- drupal_set_message(t('Field %label is required and uses the "hidden" widget. You might want to configure a default value.', array('%label' => $instance['label'])), 'warning');
- }
- }
- catch (\Exception $e) {
- drupal_set_message(t('There was a problem changing the widget for field %label.', array('%label' => $instance['label'])), 'error');
- }
-
- $form_state['redirect'] = $this->getNextDestination();
- }
-
-}
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php
new file mode 100644
index 0000000..d2ab86a
--- /dev/null
+++ b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php
@@ -0,0 +1,161 @@
+get('plugin.manager.entity'),
+ $container->get('plugin.manager.field.widget')
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormID() {
+ return 'field_ui_form_display_overview_form';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function buildFieldRow($field_id, FieldInstanceInterface $instance, EntityDisplayBaseInterface $entity_display, array $form, array &$form_state) {
+ $field_row = parent::buildFieldRow($field_id, $instance, $entity_display, $form, $form_state);
+
+ // Update the (invisible) title of the 'plugin' column.
+ $field_row['plugin']['#title'] = t('Formatter for @title', array('@title' => $instance['label']));
+ if (!empty($field_row['plugin']['settings_edit_form']) && ($plugin = $entity_display->getRenderer($field_id))) {
+ $plugin_type_info = $plugin->getPluginDefinition();
+ $field_row['plugin']['settings_edit_form']['label']['#markup'] = t('Widget settings:') . ' ' . $plugin_type_info['label'] . '';
+ }
+
+ return $field_row;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getEntityDisplay($mode) {
+ return entity_get_form_display($this->entity_type, $this->bundle, $mode);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getExtraFields() {
+ return field_info_extra_fields($this->entity_type, $this->bundle, 'form');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getPlugin($instance, $configuration) {
+ $plugin = NULL;
+
+ if ($configuration && $configuration['type'] != 'hidden') {
+ $plugin = $this->pluginManager->getInstance(array(
+ 'field_definition' => $instance,
+ 'form_mode' => $this->mode,
+ 'configuration' => $configuration
+ ));
+ }
+
+ return $plugin;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getDefaultPlugin($field_type) {
+ return $this->fieldTypes[$field_type]['default_widget'];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getDisplayModes() {
+ return entity_get_form_modes($this->entity_type);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getDisplayModeSettings() {
+ return field_form_mode_settings($this->entity_type, $this->bundle);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function saveDisplayModeSettings($display_mode_settings) {
+ $bundle_settings = field_bundle_settings($this->entity_type, $this->bundle);
+ $bundle_settings['form_modes'] = NestedArray::mergeDeep($bundle_settings['form_modes'], $display_mode_settings);
+ field_bundle_settings($this->entity_type, $this->bundle, $bundle_settings);
+ }
+
+ /**
+ * {@inheritdoc
+ */
+ protected function getTableHeader() {
+ return array(
+ t('Field'),
+ t('Weight'),
+ t('Parent'),
+ array('data' => t('Widget'), 'colspan' => 3),
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getOverviewPath($mode) {
+ return $this->entityManager->getAdminPath($this->entity_type, $this->bundle) . "/form-display/$mode";
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function alterSettingsForm(array &$settings_form, $plugin, FieldInstanceInterface $instance, array $form, array &$form_state) {
+ $context = array(
+ 'widget' => $plugin,
+ 'field' => $instance->getField(),
+ 'instance' => $instance,
+ 'form_mode' => $this->mode,
+ 'form' => $form,
+ );
+ drupal_alter('field_widget_settings_form', $settings_form, $form_state, $context);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function alterSettingsSummary(array &$summary, $plugin, FieldInstanceInterface $instance) {
+ $context = array(
+ 'widget' => $plugin,
+ 'field' => $instance->getField(),
+ 'instance' => $instance,
+ 'form_mode' => $this->mode,
+ );
+ drupal_alter('field_widget_settings_summary', $summary, $context);
+ }
+
+}
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php b/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php
index ecf8de4..67b742b 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php
@@ -83,6 +83,11 @@ public function buildForm(array $form, array &$form_state, $entity_type = NULL,
$this->entity_type = $entity_type;
$this->bundle = $bundle;
$this->adminPath = $this->entityManager->getAdminPath($this->entity_type, $this->bundle);
+
+ // When displaying the form, make sure the list of fields is up-to-date.
+ if (empty($form_state['post'])) {
+ field_info_cache_clear();
+ }
}
/**
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php b/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php
index 55477a0..e994202 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php
@@ -68,13 +68,6 @@ public function routes(RouteBuildEvent $event) {
$collection->add("field_ui.field_edit.$entity_type", $route);
$route = new Route(
- "$path/fields/{field_instance}/widget-type",
- array('_form' => '\Drupal\field_ui\Form\FieldWidgetTypeForm'),
- array('_permission' => 'administer ' . $entity_type . ' fields')
- );
- $collection->add("field_ui.widget_type.$entity_type", $route);
-
- $route = new Route(
"$path/fields/{field_instance}/delete",
array('_entity_form' => 'field_instance.delete'),
array('_permission' => 'administer ' . $entity_type . ' fields')
@@ -94,6 +87,24 @@ public function routes(RouteBuildEvent $event) {
$collection->add("field_ui.overview.$entity_type", $route);
$route = new Route(
+ "$path/form-display",
+ array('_form' => '\Drupal\field_ui\FormDisplayOverview') + $defaults,
+ array('_permission' => 'administer ' . $entity_type . ' form display')
+ );
+ $collection->add("field_ui.form_display_overview.$entity_type", $route);
+
+ foreach (entity_get_form_modes($entity_type) as $form_mode => $form_mode_info) {
+ $route = new Route(
+ "$path/form-display/$form_mode",
+ array(
+ '_form' => '\Drupal\field_ui\FormDisplayOverview',
+ 'mode' => $form_mode,
+ ) + $defaults,
+ array('_field_ui_form_mode_access' => 'administer ' . $entity_type . ' form display'));
+ $collection->add("field_ui.form_display_overview.$entity_type.$form_mode", $route);
+ }
+
+ $route = new Route(
"$path/display",
array('_form' => '\Drupal\field_ui\DisplayOverview') + $defaults,
array('_permission' => 'administer ' . $entity_type . ' display')
@@ -105,7 +116,7 @@ public function routes(RouteBuildEvent $event) {
"$path/display/$view_mode",
array(
'_form' => '\Drupal\field_ui\DisplayOverview',
- 'view_mode' => $view_mode,
+ 'mode' => $view_mode,
) + $defaults,
array('_field_ui_view_mode_access' => 'administer ' . $entity_type . ' display'));
$collection->add("field_ui.display_overview.$entity_type.$view_mode", $route);
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUIRouteTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUIRouteTest.php
index 32d2a71..669b58e 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUIRouteTest.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUIRouteTest.php
@@ -46,7 +46,9 @@ public function setUp() {
*/
public function testFieldUIRoutes() {
$this->drupalGet('field-ui-test-no-bundle/manage/fields');
- $this->assertText('No fields are present yet.');
+ // @todo Bring back this assertion in https://drupal.org/node/1963340.
+ // @see \Drupal\field_ui\FieldOverview::getRegions()
+ //$this->assertText('No fields are present yet.');
$this->drupalGet('admin/structure/types/manage/article/fields');
$this->assertTitle('Article | Drupal');
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php
index bc44cbd..c836023 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php
@@ -26,7 +26,7 @@ function setUp() {
parent::setUp();
// Create test user.
- $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer node display', 'administer taxonomy', 'administer taxonomy_term fields', 'administer taxonomy_term display', 'administer users', 'administer user display', 'bypass node access'));
+ $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer taxonomy', 'administer taxonomy_term fields', 'administer taxonomy_term display', 'administer users', 'administer user display', 'bypass node access'));
$this->drupalLogin($admin_user);
// Create content type, with underscores.
@@ -67,10 +67,8 @@ function fieldUIAddNewField($bundle_path, $initial_edit, $field_edit = array(),
// Use 'test_field' field type by default.
$initial_edit += array(
'fields[_add_new_field][type]' => 'test_field',
- 'fields[_add_new_field][widget_type]' => 'test_field_widget',
);
$label = $initial_edit['fields[_add_new_field][label]'];
- $field_name = $initial_edit['fields[_add_new_field][field_name]'];
// First step : 'Add new field' on the 'Manage fields' page.
$this->drupalPost("$bundle_path/fields", $initial_edit, t('Save'));
@@ -101,12 +99,7 @@ function fieldUIAddNewField($bundle_path, $initial_edit, $field_edit = array(),
* form).
*/
function fieldUIAddExistingField($bundle_path, $initial_edit, $instance_edit = array()) {
- // Use 'test_field_widget' by default.
- $initial_edit += array(
- 'fields[_add_existing_field][widget_type]' => 'test_field_widget',
- );
$label = $initial_edit['fields[_add_existing_field][label]'];
- $field_name = $initial_edit['fields[_add_existing_field][field_name]'];
// First step : 'Re-use existing field' on the 'Manage fields' page.
$this->drupalPost("$bundle_path/fields", $initial_edit, t('Save'));
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php
index c643cd0..c6d712d 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php
@@ -24,7 +24,7 @@ class ManageDisplayTest extends FieldUiTestBase {
public static function getInfo() {
return array(
'name' => 'Manage display',
- 'description' => 'Test the Field UI "Manage display" screens.',
+ 'description' => 'Test the Field UI "Manage display" and "Manage form display" screens.',
'group' => 'Field UI',
);
}
@@ -81,17 +81,82 @@ function testFormatterUI() {
// Click on the formatter settings button to open the formatter settings
// form.
- $this->drupalPostAJAX(NULL, array(), "field_test_formatter_settings_edit");
+ $this->drupalPostAJAX(NULL, array(), "field_test_settings_edit");
// Assert that the field added in
// field_test_field_formatter_settings_form_alter() is present.
$fieldname = 'fields[field_test][settings_edit_form][settings][field_test_formatter_settings_form_alter]';
$this->assertField($fieldname, 'The field added in hook_field_formatter_settings_form_alter() is present on the settings form.');
$edit = array($fieldname => 'foo');
- $this->drupalPostAJAX(NULL, $edit, "field_test_formatter_settings_update");
+ $this->drupalPostAJAX(NULL, $edit, "field_test_plugin_settings_update");
// Confirm that the settings are updated on the settings form.
- $this->drupalPostAJAX(NULL, array(), "field_test_formatter_settings_edit");
+ $this->drupalPostAJAX(NULL, array(), "field_test_settings_edit");
+ $this->assertFieldByName($fieldname, 'foo');
+ }
+
+ /**
+ * Tests widget settings.
+ */
+ public function testWidgetUI() {
+ $manage_fields = 'admin/structure/types/manage/' . $this->type;
+ $manage_display = $manage_fields . '/form-display';
+
+ // Create a field, and a node with some data for the field.
+ $edit = array(
+ 'fields[_add_new_field][label]' => 'Test field',
+ 'fields[_add_new_field][field_name]' => 'test',
+ );
+ $this->fieldUIAddNewField($manage_fields, $edit);
+
+ // Clear the test-side cache and get the saved field instance.
+ $display = entity_get_form_display('node', $this->type, 'default');
+ $display_options = $display->getComponent('field_test');
+ $widget_type = $display_options['type'];
+ $default_settings = field_info_widget_settings($widget_type);
+ $setting_name = key($default_settings);
+ $setting_value = $display_options['settings'][$setting_name];
+
+ // Display the "Manage form display" screen and check that the expected
+ // widget is selected.
+ $this->drupalGet($manage_display);
+ $this->assertFieldByName('fields[field_test][type]', $widget_type, 'The expected widget is selected.');
+ $this->assertText("$setting_name: $setting_value", 'The expected summary is displayed.');
+
+ // Change the widget and check that the summary is updated.
+ $edit = array('fields[field_test][type]' => 'test_field_widget_multiple', 'refresh_rows' => 'field_test');
+ $this->drupalPostAJAX(NULL, $edit, array('op' => t('Refresh')));
+ $widget_type = 'test_field_widget_multiple';
+ $default_settings = field_info_widget_settings($widget_type);
+ $setting_name = key($default_settings);
+ $setting_value = $default_settings[$setting_name];
+ $this->assertFieldByName('fields[field_test][type]', $widget_type, 'The expected widget is selected.');
+ $this->assertText("$setting_name: $setting_value", 'The expected summary is displayed.');
+
+ // Submit the form and check that the display is updated.
+ $this->drupalPost(NULL, array(), t('Save'));
+ $display = entity_get_form_display('node', $this->type, 'default');
+ $display_options = $display->getComponent('field_test');
+ $current_widget = $display_options['type'];
+ $current_setting_value = $display_options['settings'][$setting_name];
+ $this->assertEqual($current_widget, $widget_type, 'The widget was updated.');
+ $this->assertEqual($current_setting_value, $setting_value, 'The setting was updated.');
+
+ // Assert that hook_field_formatter_settings_summary_alter() is called.
+ $this->assertText('field_test_field_widget_settings_summary_alter');
+
+ // Click on the widget settings button to open the widget settings form.
+ $this->drupalPostAJAX(NULL, array(), "field_test_settings_edit");
+
+ // Assert that the field added in
+ // field_test_field_widget_settings_form_alter() is present.
+ $fieldname = 'fields[field_test][settings_edit_form][settings][field_test_widget_settings_form_alter]';
+ $this->assertField($fieldname, 'The field added in hook_field_widget_settings_form_alter() is present on the settings form.');
+ $edit = array($fieldname => 'foo');
+ $this->drupalPostAJAX(NULL, $edit, "field_test_plugin_settings_update");
+
+ // Confirm that the settings are updated on the settings form.
+ $this->drupalPostAJAX(NULL, array(), "field_test_settings_edit");
$this->assertFieldByName($fieldname, 'foo');
}
@@ -137,7 +202,7 @@ function testViewModeCustom() {
// Specialize the 'rss' mode, check that the field is displayed the same.
$edit = array(
- "view_modes_custom[rss]" => TRUE,
+ "display_modes_custom[rss]" => TRUE,
);
$this->drupalPost('admin/structure/types/manage/' . $this->type . '/display', $edit, t('Save'));
$this->assertNodeViewText($node, 'rss', $output['field_test_with_prepare_view'], "The field is displayed as expected in newly specialized 'rss' mode.");
@@ -153,14 +218,14 @@ function testViewModeCustom() {
// Set the view mode back to 'default', check that the field is displayed
// accordingly.
$edit = array(
- "view_modes_custom[rss]" => FALSE,
+ "display_modes_custom[rss]" => FALSE,
);
$this->drupalPost('admin/structure/types/manage/' . $this->type . '/display', $edit, t('Save'));
$this->assertNodeViewText($node, 'rss', $output['field_test_with_prepare_view'], "The field is displayed as expected when 'rss' mode is set back to 'default' settings.");
// Specialize the view mode again.
$edit = array(
- "view_modes_custom[rss]" => TRUE,
+ "display_modes_custom[rss]" => TRUE,
);
$this->drupalPost('admin/structure/types/manage/' . $this->type . '/display', $edit, t('Save'));
// Check that the previous settings for the view mode have been kept.
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
index 56370ad..cd7037f 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
@@ -89,7 +89,6 @@ function manageFieldsPage($type = '') {
t('Label'),
t('Machine name'),
t('Field type'),
- t('Widget'),
t('Operations'),
);
foreach ($table_headers as $table_header) {
@@ -145,7 +144,6 @@ function updateField() {
$this->drupalGet('admin/structure/types/manage/' . $this->type . '/fields/' . $instance_id);
$edit = array(
'instance[settings][test_instance_setting]' => $string,
- 'instance[widget][settings][test_widget_setting]' => $string,
);
$this->drupalPost(NULL, $edit, t('Save settings'));
@@ -236,13 +234,9 @@ function assertFieldSettings($bundle, $field_name, $string = 'dummy test string'
$field = field_info_field($field_name);
$this->assertTrue($field['settings']['test_field_setting'] == $string, 'Field settings were found.');
- // Assert instance and widget settings.
+ // Assert instance settings.
$instance = field_info_instance($entity_type, $field_name, $bundle);
$this->assertTrue($instance['settings']['test_instance_setting'] == $string, 'Field instance settings were found.');
-
- // Assert widget settings.
- $widget_configuration = entity_get_form_display($entity_type, $bundle, 'default')->getComponent($field_name);
- $this->assertTrue($widget_configuration['settings']['test_widget_setting'] == $string, 'Field widget settings were found.');
}
/**
@@ -411,11 +405,11 @@ function testLockedField() {
// Check that the links for edit and delete are not present.
$this->drupalGet('admin/structure/types/manage/' . $this->type . '/fields');
- $locked = $this->xpath('//tr[@id=:field_name]/td[7]', array(':field_name' => $field->id()));
+ $locked = $this->xpath('//tr[@id=:field_name]/td[4]', array(':field_name' => $field->id()));
$this->assertTrue(in_array('Locked', $locked), 'Field is marked as Locked in the UI');
- $edit_link = $this->xpath('//tr[@id=:field_name]/td[7]', array(':field_name' => $field->id()));
+ $edit_link = $this->xpath('//tr[@id=:field_name]/td[4]', array(':field_name' => $field->id()));
$this->assertFalse(in_array('edit', $edit_link), 'Edit option for locked field is not present the UI');
- $delete_link = $this->xpath('//tr[@id=:field_name]/td[8]', array(':field_name' => $field->id()));
+ $delete_link = $this->xpath('//tr[@id=:field_name]/td[4]', array(':field_name' => $field->id()));
$this->assertFalse(in_array('delete', $delete_link), 'Delete option for locked field is not present the UI');
}
@@ -454,15 +448,6 @@ function testHiddenFields() {
$bundle_path = 'admin/structure/types/manage/article/fields/';
$this->drupalGet($bundle_path);
$this->assertFalse($this->xpath('//select[@id="edit-add-existing-field-field-name"]//option[@value=:field_name]', array(':field_name' => $field_name)), "The 're-use existing field' select respects field types 'no_ui' property.");
-
- // Remove the form display component to check the fallback label.
- entity_get_form_display('node', $this->type, 'default')
- ->removeComponent($field_name)
- ->save();
-
- $this->drupalGet('admin/structure/types/manage/' . $this->type . '/fields/');
- $this->assertLinkByHref(url('admin/structure/types/manage/' . $this->type . '/fields/node.' . $this->type . '.' . $field_name . '/widget-type'));
- $this->assertLink('- Hidden -');
}
/**
@@ -488,7 +473,6 @@ function testDuplicateFieldName() {
'fields[_add_new_field][field_name]' => 'tags',
'fields[_add_new_field][label]' => $this->randomName(),
'fields[_add_new_field][type]' => 'taxonomy_term_reference',
- 'fields[_add_new_field][widget_type]' => 'options_select',
);
$url = 'admin/structure/types/manage/' . $this->type . '/fields';
$this->drupalPost($url, $edit, t('Save'));
@@ -498,49 +482,6 @@ function testDuplicateFieldName() {
}
/**
- * Tests changing the widget used by a field.
- */
- function testWidgetChange() {
- $url_fields = 'admin/structure/types/manage/article/fields';
- $url_tags_widget = $url_fields . '/node.article.field_tags/widget-type';
-
- // Check that the field_tags field currently uses the 'options_select'
- // widget.
- $entity_form_display = entity_get_form_display('node', 'article', 'default')->getComponent('field_tags');
- $this->assertEqual($entity_form_display['type'], 'options_select');
-
- // Check that the "Manage fields" page shows the correct widget type.
- $this->drupalGet($url_fields);
- $link = current($this->xpath('//a[contains(@href, :href)]', array(':href' => $url_tags_widget)));
- $this->assertEqual((string) $link, 'Select list');
-
- // Go to the 'Widget type' form and check that the correct widget is
- // selected.
- $this->drupalGet($url_tags_widget);
- $this->assertFieldByXPath("//select[@name='widget_type']", 'options_select');
-
- // Change the widget type.
- $edit = array(
- 'widget_type' => 'options_buttons',
- );
- $this->drupalPost(NULL, $edit, t('Continue'));
-
- // Check that the "Manage fields" page shows the correct widget type.
- $link = current($this->xpath('//a[contains(@href, :href)]', array(':href' => $url_tags_widget)));
- $this->assertEqual((string) $link, 'Check boxes/radio buttons');
-
- // Check that the field uses the newly set widget.
- field_cache_clear();
- $widget_configuration = entity_get_form_display('node', 'article', 'default')->getComponent('field_tags');
- $this->assertEqual($widget_configuration['type'], 'options_buttons');
-
- // Go to the 'Widget type' form and check that the correct widget is
- // selected.
- $this->drupalGet($url_tags_widget);
- $this->assertFieldByXPath("//select[@name='widget_type']", 'options_buttons');
- }
-
- /**
* Tests that deletion removes fields and instances as expected for a term.
*/
function testDeleteTaxonomyField() {
diff --git a/core/modules/file/lib/Drupal/file/Plugin/field/widget/FileWidget.php b/core/modules/file/lib/Drupal/file/Plugin/field/widget/FileWidget.php
index c63df17..63564fa 100644
--- a/core/modules/file/lib/Drupal/file/Plugin/field/widget/FileWidget.php
+++ b/core/modules/file/lib/Drupal/file/Plugin/field/widget/FileWidget.php
@@ -51,6 +51,15 @@ public function settingsForm(array $form, array &$form_state) {
/**
* {@inheritdoc}
+ */
+ public function settingsSummary() {
+ $summary = array();
+ $summary[] = t('Progress indicator: @progress_indicator', array('@progress_indicator' => $this->getSetting('progress_indicator')));
+ return $summary;
+ }
+
+ /**
+ * Overrides \Drupal\field\Plugin\Type\Widget\WidgetBase::formMultipleElements().
*
* Special handling for draggable multiple widgets and 'add more' button.
*/
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php
index 7847a16..e241dea 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php
@@ -48,7 +48,7 @@ function testFileFieldRSSContent() {
// RSS display must be added manually.
$this->drupalGet("admin/structure/types/manage/$type_name/display");
$edit = array(
- "view_modes_custom[rss]" => '1',
+ "display_modes_custom[rss]" => '1',
);
$this->drupalPost(NULL, $edit, t('Save'));
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php
index 2389423..2267b1a 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php
@@ -253,7 +253,6 @@ function testPrivateFileComment() {
'fields[_add_new_field][label]' => $label = $this->randomName(),
'fields[_add_new_field][field_name]' => $name = strtolower($this->randomName()),
'fields[_add_new_field][type]' => 'file',
- 'fields[_add_new_field][widget_type]' => 'file_generic',
);
$this->drupalPost('admin/structure/types/manage/article/comment/fields', $edit, t('Save'));
$edit = array('field[settings][uri_scheme]' => 'private');
diff --git a/core/modules/image/lib/Drupal/image/Plugin/field/widget/ImageWidget.php b/core/modules/image/lib/Drupal/image/Plugin/field/widget/ImageWidget.php
index 3ad6e0f..d0ae8fa 100644
--- a/core/modules/image/lib/Drupal/image/Plugin/field/widget/ImageWidget.php
+++ b/core/modules/image/lib/Drupal/image/Plugin/field/widget/ImageWidget.php
@@ -33,7 +33,7 @@
class ImageWidget extends FileWidget {
/**
- * Overrides \Drupal\file\Plugin\field\widget\FileWidget::settingsForm().
+ * {@inheritdoc}
*/
public function settingsForm(array $form, array &$form_state) {
$element = parent::settingsForm($form, $form_state);
@@ -53,6 +53,30 @@ public function settingsForm(array $form, array &$form_state) {
/**
* {@inheritdoc}
+ */
+ public function settingsSummary() {
+ $summary = parent::settingsSummary();
+
+ $image_styles = image_style_options(FALSE);
+ // Unset possible 'No defined styles' option.
+ unset($image_styles['']);
+ // Styles could be lost because of enabled/disabled modules that defines
+ // their styles in code.
+ $image_style_setting = $this->getSetting('preview_image_style');
+ if (isset($image_styles[$image_style_setting])) {
+ $preview_image_style = t('Preview image style: @style', array('@style' => $image_styles[$image_style_setting]));
+ }
+ else {
+ $preview_image_style = t('Original image');
+ }
+
+ array_unshift($summary, $preview_image_style);
+
+ return $summary;
+ }
+
+ /**
+ * Overrides \Drupal\file\Plugin\field\widget\FileWidget::formMultipleElements().
*
* Special handling for draggable multiple widgets and 'add more' button.
*/
diff --git a/core/modules/link/lib/Drupal/link/Plugin/field/widget/LinkWidget.php b/core/modules/link/lib/Drupal/link/Plugin/field/widget/LinkWidget.php
index f960613..d5bc6fd 100644
--- a/core/modules/link/lib/Drupal/link/Plugin/field/widget/LinkWidget.php
+++ b/core/modules/link/lib/Drupal/link/Plugin/field/widget/LinkWidget.php
@@ -105,6 +105,30 @@ public function settingsForm(array $form, array &$form_state) {
}
/**
+ * {@inheritdoc}
+ */
+ public function settingsSummary() {
+ $summary = array();
+
+ $placeholder_title = $this->getSetting('placeholder_title');
+ $placeholder_url = $this->getSetting('placeholder_url');
+ if (empty($placeholder_title) && empty($placeholder_url)) {
+ $summary[] = t('No placeholders');
+ }
+ else {
+ if (!empty($placeholder_title)) {
+ $summary[] = t('Title placeholder: @placeholder_title', array('@placeholder_title' => $placeholder_title));
+ }
+ if (!empty($placeholder_url)) {
+ $summary[] = t('URL placeholder: @placeholder_url', array('@placeholder_url' => $placeholder_url));
+ }
+ }
+
+ return $summary;
+ }
+
+
+ /**
* Form element validation handler for link_field_widget_form().
*
* Conditionally requires the link title if a URL value was filled in.
diff --git a/core/modules/link/lib/Drupal/link/Tests/LinkFieldUITest.php b/core/modules/link/lib/Drupal/link/Tests/LinkFieldUITest.php
index f8ff160..910ff14 100644
--- a/core/modules/link/lib/Drupal/link/Tests/LinkFieldUITest.php
+++ b/core/modules/link/lib/Drupal/link/Tests/LinkFieldUITest.php
@@ -51,7 +51,6 @@ function testFieldUI() {
'fields[_add_new_field][label]' => $label,
'fields[_add_new_field][field_name]' => $field_name,
'fields[_add_new_field][type]' => 'link',
- 'fields[_add_new_field][widget_type]' => 'link_default',
);
$this->drupalPost("$type_path/fields", $edit, t('Save'));
// Proceed to the Edit (field instance settings) page.
diff --git a/core/modules/node/lib/Drupal/node/NodeTypeListController.php b/core/modules/node/lib/Drupal/node/NodeTypeListController.php
index 12ca237..d6be67d 100644
--- a/core/modules/node/lib/Drupal/node/NodeTypeListController.php
+++ b/core/modules/node/lib/Drupal/node/NodeTypeListController.php
@@ -99,12 +99,20 @@ public function getOperations(EntityInterface $entity) {
'weight' => 0,
);
}
+ if ($this->moduleHandler->moduleExists('field_ui') && user_access('administer node form display')) {
+ $operations['manage-form-display'] = array(
+ 'title' => t('Manage form display'),
+ 'href' => $uri['path'] . '/form-display',
+ 'options' => $uri['options'],
+ 'weight' => 5,
+ );
+ }
if ($this->moduleHandler->moduleExists('field_ui') && user_access('administer node display')) {
$operations['manage-display'] = array(
'title' => t('Manage display'),
'href' => $uri['path'] . '/display',
'options' => $uri['options'],
- 'weight' => 5,
+ 'weight' => 10,
);
}
if ($entity->isLocked()) {
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php
index 27e31c6..1a0b7ed 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php
@@ -32,7 +32,7 @@ public static function getInfo() {
function setUp() {
parent::setUp();
- $web_user = $this->drupalCreateUser(array('bypass node access', 'administer content types', 'administer node fields', 'administer node display', 'administer languages', 'administer site configuration'));
+ $web_user = $this->drupalCreateUser(array('bypass node access', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer languages', 'administer site configuration'));
$this->drupalLogin($web_user);
}
@@ -75,10 +75,11 @@ function testNodeTypeInitialLanguageDefaults() {
$this->assertField('langcode', 'Language is selectable on node add/edit page when language not hidden.');
$this->assertOptionSelected('edit-langcode', 'hu', 'The initial language is the site default on the node add page after the site default language is changed.');
- // Tests if the language field can be rearranged on the manage fields tab.
- $this->drupalGet('admin/structure/types/manage/article/fields');
+ // Tests if the language field can be rearranged on the manage form display
+ // tab.
+ $this->drupalGet('admin/structure/types/manage/article/form-display');
$language_field = $this->xpath('//*[@id="language"]');
- $this->assert(!empty($language_field), 'Language field is visible on manage fields tab.');
+ $this->assert(!empty($language_field), 'Language field is visible on manage form display tab.');
// Tests if the language field can be rearranged on the manage display tab.
$this->drupalGet('admin/structure/types/manage/article/display');
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 9d04a63..d9a365d 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -119,6 +119,9 @@ function node_help($path, $arg) {
case 'admin/structure/types/add':
return '
' . t('Individual content types can have different fields, behaviors, and permissions assigned to them.') . '
';
+ case 'admin/structure/types/manage/%/form-display':
+ return '
' . t('Content items can be edited using different form modes. Here, you can define which fields are shown and hidden when %type content is edited in each form mode, and define how the field form widgets are displayed in each form mode.', array('%type' => node_type_get_label($arg[4]))) . '
' . t('Content items can be displayed using different view modes: Teaser, Full content, Print, RSS, etc. Teaser is a short format that is typically used in lists of multiple content items. Full content is typically used when the content is displayed on its own page.') . '
' .
diff --git a/core/modules/number/lib/Drupal/number/Plugin/field/widget/NumberWidget.php b/core/modules/number/lib/Drupal/number/Plugin/field/widget/NumberWidget.php
index 39eddf9..1d628ba 100644
--- a/core/modules/number/lib/Drupal/number/Plugin/field/widget/NumberWidget.php
+++ b/core/modules/number/lib/Drupal/number/Plugin/field/widget/NumberWidget.php
@@ -47,6 +47,23 @@ public function settingsForm(array $form, array &$form_state) {
/**
* {@inheritdoc}
*/
+ public function settingsSummary() {
+ $summary = array();
+
+ $placeholder = $this->getSetting('placeholder');
+ if (!empty($placeholder)) {
+ $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
+ }
+ else {
+ $summary[] = t('No placeholder');
+ }
+
+ return $summary;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) {
$value = isset($items[$delta]['value']) ? $items[$delta]['value'] : NULL;
$field_settings = $this->getFieldSettings();
diff --git a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
index 904509c..8bea406 100644
--- a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
+++ b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
@@ -167,7 +167,6 @@ function testNumberIntegerField() {
'fields[_add_new_field][label]'=> $label,
'fields[_add_new_field][field_name]' => $field_name,
'fields[_add_new_field][type]' => 'number_integer',
- 'fields[_add_new_field][widget_type]' => 'number',
);
$this->drupalPost(NULL, $edit, t('Save'));
diff --git a/core/modules/options/lib/Drupal/options/Plugin/field/widget/OnOffWidget.php b/core/modules/options/lib/Drupal/options/Plugin/field/widget/OnOffWidget.php
index fd0d230..25f9865 100644
--- a/core/modules/options/lib/Drupal/options/Plugin/field/widget/OnOffWidget.php
+++ b/core/modules/options/lib/Drupal/options/Plugin/field/widget/OnOffWidget.php
@@ -44,6 +44,18 @@ public function settingsForm(array $form, array &$form_state) {
/**
* {@inheritdoc}
*/
+ public function settingsSummary() {
+ $summary = array();
+
+ $display_label = $this->getSetting('display_label');
+ $summary[] = t('Use field label: @display_label', array('@display_label' => ($display_label ? t('Yes') : 'No')));
+
+ return $summary;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) {
$element = parent::formElement($items, $delta, $element, $langcode, $form, $form_state);
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
index 8d335c3..dbc1876 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
@@ -530,7 +530,7 @@ function testOnOffCheckbox() {
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
// Create admin user.
- $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer taxonomy'));
+ $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer taxonomy'));
$this->drupalLogin($admin_user);
// Create a test field instance.
@@ -549,39 +549,37 @@ function testOnOffCheckbox() {
))
->save();
- // Go to the edit page and check if the default settings works as expected
- $fieldEditUrl = 'admin/structure/types/manage/page/fields/node.page.bool';
+ // Go to the form display page and check if the default settings works as
+ // expected.
+ $fieldEditUrl = 'admin/structure/types/manage/page/form-display';
$this->drupalGet($fieldEditUrl);
+ $field_name = $this->bool['field_name'];
+ // Click on the widget settings button to open the widget settings form.
+ $this->drupalPostAJAX(NULL, array(), $field_name . "_settings_edit");
+
$this->assertText(
'Use field label instead of the "On value" as label',
t('Display setting checkbox available.')
);
- $this->assertFieldByXPath(
- '*//label[@for="edit-' . $this->bool['field_name'] . '-und" and text()="MyOnValue"]',
- TRUE,
- t('Default case shows "On value"')
- );
+ // Enable setting.
+ $edit = array('fields[' . $field_name . '][settings_edit_form][settings][display_label]' => 1);
+ $this->drupalPostAJAX(NULL, $edit, $field_name . "_plugin_settings_update");
+ $this->drupalPost(NULL, NULL, 'Save');
- // Enable setting
- $edit = array('instance[widget][settings][display_label]' => 1);
- // Save the new Settings
- $this->drupalPost($fieldEditUrl, $edit, t('Save settings'));
-
- // Go again to the edit page and check if the setting
- // is stored and has the expected effect
+ // Go again to the form display page and check if the setting
+ // is stored and has the expected effect.
$this->drupalGet($fieldEditUrl);
+ $this->assertText('Use field label: Yes', 'Checking the display settings checkbox updated the value.');
+
+ $this->drupalPostAJAX(NULL, array(), $field_name . "_settings_edit");
$this->assertText(
'Use field label instead of the "On value" as label',
t('Display setting checkbox is available')
);
- $this->assertFieldChecked(
- 'edit-instance-widget-settings-display-label',
- t('Display settings checkbox checked')
- );
$this->assertFieldByXPath(
- '*//label[@for="edit-' . $this->bool['field_name'] . '-und" and text()="' . $this->bool['field_name'] . '"]',
+ '*//input[@id="edit-fields-' . $field_name . '-settings-edit-form-settings-display-label" and @value="1"]',
TRUE,
t('Display label changes label of the checkbox')
);
diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module
index 79b2854..40a0c76 100644
--- a/core/modules/overlay/overlay.module
+++ b/core/modules/overlay/overlay.module
@@ -100,7 +100,7 @@ function overlay_field_extra_fields() {
/**
* Implements hook_form_FORM_ID_alter().
*/
-function overlay_form_user_profile_form_alter(&$form, &$form_state) {
+function overlay_form_user_form_alter(&$form, &$form_state) {
$account = $form_state['controller']->getEntity();
if (user_access('access overlay', $account)) {
$account_data = Drupal::service('user.data')->get('overlay', $account->id(), 'enabled');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php
index ff1bad3..cc6546a 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php
@@ -44,11 +44,8 @@ function setUp() {
'field_name' => 'test_multiple',
'bundle' => 'user',
'label' => 'Test a multiple valued field',
- 'settings' => array(
- 'user_register_form' => TRUE,
- ),
))->save();
- entity_get_form_display('user', 'user', 'default')
+ entity_get_form_display('user', 'user', 'register')
->setComponent('test_multiple', array(
'type' => 'text_textfield',
'weight' => 0,
diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
index 4bdfbb5..fd1c08f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
@@ -149,10 +149,6 @@ function testBreadCrumbs() {
"admin/structure/types/manage/$type/fields" => t('Manage fields'),
);
$this->assertBreadcrumb("admin/structure/types/manage/$type/fields/node.$type.body", $trail);
- $trail += array(
- "admin/structure/types/manage/$type/fields/node.$type.body" => t('Body'),
- );
- $this->assertBreadcrumb("admin/structure/types/manage/$type/fields/node.$type.body/widget-type", $trail);
// Verify Filter text format administration breadcrumbs.
$filter_formats = filter_formats();
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php
index 2dfeae7..79abf93 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php
@@ -170,7 +170,9 @@ function testFieldUpgradeToConfig() {
'settings' => array(
'display_summary' => TRUE,
'text_processing' => 1,
- 'user_register_form' => FALSE,
+ // This setting has been removed in field_update_8005(). We keep it
+ // here, commented out, to prove that the upgrade path is working.
+ //'user_register_form' => FALSE,
),
'status' => 1,
'langcode' => 'und',
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index ae4131d..3d7896b 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -2556,7 +2556,7 @@ function system_custom_theme() {
/**
* Implements hook_form_FORM_ID_alter().
*/
-function system_form_user_profile_form_alter(&$form, &$form_state) {
+function system_form_user_form_alter(&$form, &$form_state) {
if (config('system.timezone')->get('user.configurable')) {
system_user_timezone($form, $form_state);
}
@@ -2608,7 +2608,7 @@ function system_user_timezone(&$form, &$form_state) {
$form['timezone']['timezone'] = array(
'#type' => 'select',
'#title' => t('Time zone'),
- '#default_value' => isset($account->timezone) ? $account->timezone : ($account->uid == $user->uid ? config('system.date')->get('timezone.default') : ''),
+ '#default_value' => isset($account->timezone) ? $account->timezone : ($account->uid == $user->uid ? config('system.timezone')->get('default') : ''),
'#options' => system_time_zones($account->uid != $user->uid),
'#description' => t('Select the desired local time and time zone. Dates and times throughout this site will be displayed using this time zone.'),
);
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php
index 78f8fb3..10c9aef 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php
@@ -47,6 +47,24 @@ public function settingsForm(array $form, array &$form_state) {
/**
* {@inheritdoc}
*/
+ public function settingsSummary() {
+ $summary = array();
+
+ $summary[] = t('Textfield size: !size', array('!size' => $this->getSetting('size')));
+ $placeholder = $this->getSetting('placeholder');
+ if (!empty($placeholder)) {
+ $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
+ }
+ else {
+ $summary[] = t('No placeholder');
+ }
+
+ return $summary;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) {
$tags = array();
foreach ($items as $item) {
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php
index 1b8bb3b..c9b8078 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php
@@ -80,7 +80,7 @@ function testTaxonomyRss() {
// RSS display must be added manually.
$this->drupalGet("admin/structure/types/manage/article/display");
$edit = array(
- "view_modes_custom[rss]" => '1',
+ "display_modes_custom[rss]" => '1',
);
$this->drupalPost(NULL, $edit, t('Save'));
diff --git a/core/modules/telephone/lib/Drupal/telephone/Plugin/field/widget/TelephoneDefaultWidget.php b/core/modules/telephone/lib/Drupal/telephone/Plugin/field/widget/TelephoneDefaultWidget.php
index 66884fe..444dc3a 100644
--- a/core/modules/telephone/lib/Drupal/telephone/Plugin/field/widget/TelephoneDefaultWidget.php
+++ b/core/modules/telephone/lib/Drupal/telephone/Plugin/field/widget/TelephoneDefaultWidget.php
@@ -28,6 +28,7 @@
*/
class TelephoneDefaultWidget extends WidgetBase {
+
/**
* Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::settingsForm().
*/
@@ -42,6 +43,23 @@ public function settingsForm(array $form, array &$form_state) {
}
/**
+ * {@inheritdoc}
+ */
+ public function settingsSummary() {
+ $summary = array();
+
+ $placeholder = $this->getSetting('placeholder');
+ if (!empty($placeholder)) {
+ $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
+ }
+ else {
+ $summary[] = t('No placeholder');
+ }
+
+ return $summary;
+ }
+
+ /**
* Implements \Drupal\field\Plugin\Type\Widget\WidgetInterface::formElement().
*/
public function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) {
diff --git a/core/modules/text/lib/Drupal/text/Plugin/field/widget/TextareaWidget.php b/core/modules/text/lib/Drupal/text/Plugin/field/widget/TextareaWidget.php
index 2fe37a0..72eff19 100644
--- a/core/modules/text/lib/Drupal/text/Plugin/field/widget/TextareaWidget.php
+++ b/core/modules/text/lib/Drupal/text/Plugin/field/widget/TextareaWidget.php
@@ -52,6 +52,21 @@ public function settingsForm(array $form, array &$form_state) {
/**
* {@inheritdoc}
*/
+ public function settingsSummary() {
+ $summary = array();
+
+ $summary[] = t('Number of rows: !rows', array('!rows' => $this->getSetting('rows')));
+ $placeholder = $this->getSetting('placeholder');
+ if (!empty($placeholder)) {
+ $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
+ }
+
+ return $summary;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) {
$main_widget = $element + array(
'#type' => 'textarea',
diff --git a/core/modules/text/lib/Drupal/text/Plugin/field/widget/TextareaWithSummaryWidget.php b/core/modules/text/lib/Drupal/text/Plugin/field/widget/TextareaWithSummaryWidget.php
index ef7dc0d..300af18 100644
--- a/core/modules/text/lib/Drupal/text/Plugin/field/widget/TextareaWithSummaryWidget.php
+++ b/core/modules/text/lib/Drupal/text/Plugin/field/widget/TextareaWithSummaryWidget.php
@@ -33,6 +33,32 @@ class TextareaWithSummaryWidget extends TextareaWidget {
/**
* {@inheritdoc}
*/
+ public function settingsForm(array $form, array &$form_state) {
+ $element = parent::settingsForm($form, $form_state);
+ $element['summary_rows'] = array(
+ '#type' => 'number',
+ '#title' => t('Summary rows'),
+ '#default_value' => $this->getSetting('summary_rows'),
+ '#required' => TRUE,
+ '#min' => 1,
+ );
+ return $element;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function settingsSummary() {
+ $summary = parent::settingsSummary();
+
+ $summary[] = t('Number of summary rows: !rows', array('!rows' => $this->getSetting('summary_rows')));
+
+ return $summary;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) {
$element = parent::formElement($items, $delta, $element, $langcode, $form, $form_state);
diff --git a/core/modules/text/lib/Drupal/text/Plugin/field/widget/TextfieldWidget.php b/core/modules/text/lib/Drupal/text/Plugin/field/widget/TextfieldWidget.php
index 7012c75..5319aab 100644
--- a/core/modules/text/lib/Drupal/text/Plugin/field/widget/TextfieldWidget.php
+++ b/core/modules/text/lib/Drupal/text/Plugin/field/widget/TextfieldWidget.php
@@ -52,6 +52,21 @@ public function settingsForm(array $form, array &$form_state) {
/**
* {@inheritdoc}
*/
+ public function settingsSummary() {
+ $summary = array();
+
+ $summary[] = t('Textfield size: !size', array('!size' => $this->getSetting('size')));
+ $placeholder = $this->getSetting('placeholder');
+ if (!empty($placeholder)) {
+ $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
+ }
+
+ return $summary;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) {
$main_widget = $element + array(
'#type' => 'textfield',
diff --git a/core/modules/user/config/entity.form_mode.user.register.yml b/core/modules/user/config/entity.form_mode.user.register.yml
new file mode 100644
index 0000000..222bac7
--- /dev/null
+++ b/core/modules/user/config/entity.form_mode.user.register.yml
@@ -0,0 +1,4 @@
+id: user.register
+label: Register
+status: '1'
+targetEntityType: user
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
index c9a671b..4f89128 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
@@ -28,12 +28,11 @@
* "access" = "Drupal\user\UserAccessController",
* "render" = "Drupal\Core\Entity\EntityRenderController",
* "form" = {
- * "profile" = "Drupal\user\ProfileFormController",
+ * "default" = "Drupal\user\ProfileFormController",
* "register" = "Drupal\user\RegisterFormController"
* },
* "translation" = "Drupal\user\ProfileTranslationController"
* },
- * default_operation = "profile",
* base_table = "users",
* uri_callback = "user_uri",
* route_base_path = "admin/config/people/accounts",
diff --git a/core/modules/user/lib/Drupal/user/RegisterFormController.php b/core/modules/user/lib/Drupal/user/RegisterFormController.php
index f9f6b67..1b0b76f 100644
--- a/core/modules/user/lib/Drupal/user/RegisterFormController.php
+++ b/core/modules/user/lib/Drupal/user/RegisterFormController.php
@@ -42,14 +42,8 @@ public function form(array $form, array &$form_state) {
// Start with the default user account fields.
$form = parent::form($form, $form_state, $account);
- // Attach field widgets, and hide the ones where the 'user_register_form'
- // setting is not on.
+ // Attach field widgets.
field_attach_form($account, $form, $form_state);
- foreach (field_info_instances('user', 'user') as $field_name => $instance) {
- if (empty($instance['settings']['user_register_form'])) {
- $form[$field_name]['#access'] = FALSE;
- }
- }
if ($admin) {
// Redirect back to page which initiated the create request; usually
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
index 683bbda..da27a0e 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
@@ -207,7 +207,6 @@ function testRegistrationWithUserFields() {
'label' => 'Some user field',
'bundle' => 'user',
'required' => TRUE,
- 'settings' => array('user_register_form' => FALSE),
));
$instance->save();
entity_get_form_display('user', 'user', 'default')
@@ -219,8 +218,10 @@ function testRegistrationWithUserFields() {
$this->assertNoText($instance->label(), 'The field does not appear on user registration form');
// Have the field appear on the registration form.
- $instance->settings['user_register_form'] = TRUE;
- $instance->save();
+ entity_get_form_display('user', 'user', 'register')
+ ->setComponent('test_user_field', array('type' => 'test_field_widget'))
+ ->save();
+
$this->drupalGet('user/register');
$this->assertText($instance->label(), 'The field appears on user registration form');
diff --git a/core/modules/user/user.install b/core/modules/user/user.install
index 454c628..37dc770 100644
--- a/core/modules/user/user.install
+++ b/core/modules/user/user.install
@@ -1075,5 +1075,20 @@ function user_update_8019() {
}
/**
+ * Create the 'register' form mode.
+ */
+function user_update_8020() {
+ $uuid = new Uuid();
+
+ config("entity.form_mode.user.register")
+ ->set('id', "user.register")
+ ->set('uuid', $uuid->generate())
+ ->set('label', 'Register')
+ ->set('targetEntityType', 'user')
+ ->set('status', '1')
+ ->save();
+}
+
+/**
* @} End of "addtogroup updates-7.x-to-8.x".
*/
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 74d3743..eb6b4f3 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -80,7 +80,9 @@ function user_help($path, $arg) {
$output .= '';
return $output;
case 'admin/config/people/accounts/fields':
- return '
' . t('This form lets administrators add, edit, and arrange fields for storing user data.') . '
';
+ return '
' . t('This form lets administrators add and edit fields for storing user data.') . '
';
+ case 'admin/config/people/accounts/form-display':
+ return '
' . t('This form lets administrators configure how form fields should be displayed when editing a user profile.') . '
';
case 'admin/config/people/accounts/display':
return '
' . t('This form lets administrators configure how fields should be displayed when rendering a user profile page.') . '
';
case 'admin/people/search':
@@ -200,19 +202,6 @@ function user_picture_enabled() {
}
/**
- * Implements hook_field_info_alter().
- */
-function user_field_info_alter(&$info) {
- // Add the 'user_register_form' instance setting to all field types.
- foreach ($info as $field_type => &$field_type_info) {
- $field_type_info += array('instance_settings' => array());
- $field_type_info['instance_settings'] += array(
- 'user_register_form' => FALSE,
- );
- }
-}
-
-/**
* Implements hook_field_extra_fields().
*/
function user_field_extra_fields() {
@@ -1007,7 +996,7 @@ function user_menu() {
$items['user/%user/edit'] = array(
'title' => 'Edit',
'page callback' => 'entity_get_form',
- 'page arguments' => array(1, 'profile'),
+ 'page arguments' => array(1),
'access callback' => 'entity_page_access',
'access arguments' => array(1, 'update'),
'type' => MENU_LOCAL_TASK,
@@ -2101,55 +2090,6 @@ function user_node_load($nodes, $types) {
}
/**
- * Implements hook_form_FORM_ID_alter() for 'field_ui_field_instance_edit_form'.
- *
- * Add a checkbox for the 'user_register_form' instance settings on the 'Edit
- * field instance' form.
- */
-function user_form_field_ui_field_instance_edit_form_alter(&$form, &$form_state, $form_id) {
- $instance = $form_state['instance'];
-
- if ($instance['entity_type'] == 'user') {
- $form['instance']['settings']['user_register_form'] = array(
- '#type' => 'checkbox',
- '#title' => t('Display on user registration form.'),
- '#description' => t("This is compulsory for 'required' fields."),
- // Field instances created in D7 beta releases before the setting was
- // introduced might be set as 'required' and 'not shown on user_register
- // form'. We make sure the checkbox comes as 'checked' for those.
- '#default_value' => $instance['settings']['user_register_form'] || $instance['required'],
- // Display just below the 'required' checkbox.
- '#weight' => $form['instance']['required']['#weight'] + .1,
- // Disabled when the 'required' checkbox is checked.
- '#states' => array(
- 'enabled' => array('input[name="instance[required]"]' => array('checked' => FALSE)),
- ),
- // Checked when the 'required' checkbox is checked. This is done through
- // a custom behavior, since the #states system would also synchronize on
- // uncheck.
- '#attached' => array(
- 'library' => array(array('user', 'drupal.user')),
- ),
- );
-
- array_unshift($form['#submit'], 'user_form_field_ui_field_instance_edit_form_submit');
- }
-}
-
-/**
- * Additional submit handler for the 'Edit field instance' form.
- *
- * Make sure the 'user_register_form' setting is set for required fields.
- */
-function user_form_field_ui_field_instance_edit_form_submit($form, &$form_state) {
- $instance = $form_state['values']['instance'];
-
- if (!empty($instance['required'])) {
- form_set_value($form['instance']['settings']['user_register_form'], 1, $form_state);
- }
-}
-
-/**
* Implements hook_modules_installed().
*/
function user_modules_installed($modules) {
diff --git a/core/themes/seven/style.css b/core/themes/seven/style.css
index 4db790a..a0a8289 100644
--- a/core/themes/seven/style.css
+++ b/core/themes/seven/style.css
@@ -1021,23 +1021,23 @@ h1#overlay-title {
/* Field UI */
-#field-display-overview input.field-formatter-settings-edit {
+#field-display-overview input.field-plugin-settings-edit {
margin: 0;
padding: 1px 8px;
}
-#field-display-overview tr.field-formatter-settings-changed {
+#field-display-overview tr.field-plugin-settings-changed {
background: #ffffbb;
}
#field-display-overview tr.drag {
background: #ffee77;
}
-#field-display-overview tr.field-formatter-settings-editing {
+#field-display-overview tr.field-plugin-settings-editing {
background: #d5e9f2;
}
-#field-display-overview .field-formatter-settings-edit-form .form-item {
+#field-display-overview .field-plugin-settings-edit-form .form-item {
margin: 10px 0;
}
-#field-display-overview .field-formatter-settings-edit-form .form-submit {
+#field-display-overview .field-plugin-settings-edit-form .form-submit {
margin-bottom: 0;
}