Commit 9c147c3c authored by git's avatar git Committed by jmuzz
Browse files

Issue #2123559 by jasonn1234: Fixed form_state on javascript remove button.

parent 8d61cee0
......@@ -1524,9 +1524,9 @@ function field_collection_remove_js() {
* When a remove button is submitted, we need to find the item that it
* referenced and delete it. Since field UI has the deltas as a straight
* unbroken array key, we have to renumber everything down. Since we do this
* we *also* need to move all the deltas around in the $form_state['values']
* and $form_state['input'] so that user changed values follow. This is a bit
* of a complicated process.
* we *also* need to move all the deltas around in the $form_state['values'],
* $form_state['input'], and $form_state['field'] so that user changed values
* follow. This is a bit of a complicated process.
*/
function field_collection_remove_submit($form, &$form_state) {
$button = $form_state['triggering_element'];
......@@ -1552,6 +1552,7 @@ function field_collection_remove_submit($form, &$form_state) {
$moving_element = drupal_array_get_nested_value($form, $old_element_address);
$moving_element_value = drupal_array_get_nested_value($form_state['values'], $old_element_address);
$moving_element_input = drupal_array_get_nested_value($form_state['input'], $old_element_address);
$moving_element_field = drupal_array_get_nested_value($form_state['field']['#parents'], $old_element_address);
// Tell the element where it's being moved to.
$moving_element['#parents'] = $new_element_address;
......@@ -1559,6 +1560,7 @@ function field_collection_remove_submit($form, &$form_state) {
// Move the element around.
form_set_value($moving_element, $moving_element_value, $form_state);
drupal_array_set_nested_value($form_state['input'], $moving_element['#parents'], $moving_element_input);
drupal_array_set_nested_value($form_state['field']['#parents'], $moving_element['#parents'], $moving_element_field);
// Move the entity in our saved state.
if (isset($field_state['entity'][$i + 1])) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment