diff --git a/core/modules/edit/edit.module b/core/modules/edit/edit.module index 9053fa4..5cc57e5 100644 --- a/core/modules/edit/edit.module +++ b/core/modules/edit/edit.module @@ -93,7 +93,7 @@ function edit_library_info() { array( 'data' => array('edit' => array( 'metadataURL' => url('edit/metadata'), - 'fieldFormURL' => url('edit/form/!entity_type/!id/!field_name/!langcode/!view_mode/!reset_tempstore'), + 'fieldFormURL' => url('edit/form/!entity_type/!id/!field_name/!langcode/!view_mode'), 'entitySaveURL' => url('edit/entity/!entity_type/!id/!langcode'), 'context' => 'body', )), diff --git a/core/modules/edit/edit.routing.yml b/core/modules/edit/edit.routing.yml index f962cf7..ff2d1a5 100644 --- a/core/modules/edit/edit.routing.yml +++ b/core/modules/edit/edit.routing.yml @@ -6,7 +6,7 @@ edit_metadata: _permission: 'access in-place editing' edit_field_form: - pattern: '/edit/form/{entity_type}/{entity}/{field_name}/{langcode}/{view_mode}/{reset_tempstore}' + pattern: '/edit/form/{entity_type}/{entity}/{field_name}/{langcode}/{view_mode}' defaults: _controller: '\Drupal\edit\EditController::fieldForm' requirements: diff --git a/core/modules/edit/js/util.js b/core/modules/edit/js/util.js index e0aa490..05002f3 100644 --- a/core/modules/edit/js/util.js +++ b/core/modules/edit/js/util.js @@ -68,6 +68,8 @@ Drupal.edit.util.form = { * property for which this form will be loaded. * - nocssjs (required): boolean indicating whether no CSS and JS should be * returned (necessary when the form is invisible to the user). + * - Boolean reset: (required) boolean indicating whether the TempStore + * entity (if any) should be reset. * @param callback * A callback function that will receive the form to be inserted, as well as * the ajax object, necessary if the callback wants to perform other AJAX @@ -78,7 +80,10 @@ Drupal.edit.util.form = { Drupal.ajax[options.propertyID] = new Drupal.ajax(options.propertyID, options.$editorElement, { url: Drupal.edit.util.buildUrl(options.propertyID, drupalSettings.edit.fieldFormURL), event: 'edit-internal.edit', - submit: { nocssjs : options.nocssjs }, + submit: { + nocssjs: options.nocssjs, + reset: options.reset + }, progress: { type : null } // No progress indicator. }); // Implement a scoped editFieldForm AJAX command: calls the callback. diff --git a/core/modules/edit/lib/Drupal/edit/EditController.php b/core/modules/edit/lib/Drupal/edit/EditController.php index 44e8456..e34388f 100644 --- a/core/modules/edit/lib/Drupal/edit/EditController.php +++ b/core/modules/edit/lib/Drupal/edit/EditController.php @@ -135,19 +135,17 @@ public function metadata(Request $request) { * The name of the language for which the field is being edited. * @param string $view_mode * The view mode the field should be rerendered in. - * @param bool $reset_tempstore - * Set to FALSE if the existing tempstore version should be kept, or TRUE - * if the existing tempstore version should be removed. * @return \Drupal\Core\Ajax\AjaxResponse * The Ajax response. */ - public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view_mode, $reset_tempstore = FALSE) { + public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view_mode) { $response = new AjaxResponse(); - // Replace entity with tempstore copy if available, init tempstore copy - // otherwise. - if (!$reset_tempstore && ($temp_entity = Drupal::service('user.tempstore')->get('edit')->get($entity->uuid))) { - $entity = $temp_entity; + // Replace entity with tempstore copy if available and not resetting, init + // tempstore copy otherwise. + $tempstore_entity = Drupal::service('user.tempstore')->get('edit')->get($entity->uuid); + if ($tempstore_entity && !(isset($_POST['reset']) && $_POST['reset'] === 'true')) { + $entity = $tempstore_entity; } else { Drupal::service('user.tempstore')->get('edit')->set($entity->uuid, $entity);