|
@@ 427-432 (lines=6) @@
|
| 424 |
|
// entities are added or by one of the "Remove" buttons. Depending on that |
| 425 |
|
// we need to figure out where root of the widget is in the form structure |
| 426 |
|
// and use this information to return correct part of the form. |
| 427 |
|
if (!empty($trigger['#ajax']['event']) && $trigger['#ajax']['event'] == 'entity_browser_value_updated') { |
| 428 |
|
$parents = array_slice($trigger['#array_parents'], 0, -1); |
| 429 |
|
} |
| 430 |
|
elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], '_remove_')) { |
| 431 |
|
$parents = array_slice($trigger['#array_parents'], 0, -static::$deleteDepth); |
| 432 |
|
} |
| 433 |
|
|
| 434 |
|
return NestedArray::getValue($form, $parents); |
| 435 |
|
} |
|
@@ 676-683 (lines=8) @@
|
| 673 |
|
if ($is_relevant_submit) { |
| 674 |
|
// Submit was triggered by hidden "target_id" element when entities were |
| 675 |
|
// added via entity browser. |
| 676 |
|
if (!empty($trigger['#ajax']['event']) && $trigger['#ajax']['event'] == 'entity_browser_value_updated') { |
| 677 |
|
$parents = $trigger['#parents']; |
| 678 |
|
} |
| 679 |
|
// Submit was triggered by one of the "Remove" buttons. We need to walk |
| 680 |
|
// few levels up to read value of "target_id" element. |
| 681 |
|
elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], $this->fieldDefinition->getName() . '_remove_') === 0) { |
| 682 |
|
$parents = array_merge(array_slice($trigger['#parents'], 0, -static::$deleteDepth), ['target_id']); |
| 683 |
|
} |
| 684 |
|
|
| 685 |
|
if (isset($parents) && $value = $form_state->getValue($parents)) { |
| 686 |
|
$entities = EntityBrowserElement::processEntityIds($value); |