|
@@ 393-398 (lines=6) @@
|
| 390 |
|
// entities are added or by one of the "Remove" buttons. Depending on that |
| 391 |
|
// we need to figure out where root of the widget is in the form structure |
| 392 |
|
// and use this information to return correct part of the form. |
| 393 |
|
if (!empty($trigger['#ajax']['event']) && $trigger['#ajax']['event'] == 'entity_browser_value_updated') { |
| 394 |
|
$parents = array_slice($trigger['#array_parents'], 0, -1); |
| 395 |
|
} |
| 396 |
|
elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], '_remove_')) { |
| 397 |
|
$parents = array_slice($trigger['#array_parents'], 0, -static::$deleteDepth); |
| 398 |
|
} |
| 399 |
|
|
| 400 |
|
return NestedArray::getValue($form, $parents); |
| 401 |
|
} |
|
@@ 623-630 (lines=8) @@
|
| 620 |
|
if ($is_relevant_submit) { |
| 621 |
|
// Submit was triggered by hidden "target_id" element when entities were |
| 622 |
|
// added via entity browser. |
| 623 |
|
if (!empty($trigger['#ajax']['event']) && $trigger['#ajax']['event'] == 'entity_browser_value_updated') { |
| 624 |
|
$parents = $trigger['#parents']; |
| 625 |
|
} |
| 626 |
|
// Submit was triggered by one of the "Remove" buttons. We need to walk |
| 627 |
|
// few levels up to read value of "target_id" element. |
| 628 |
|
elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], $this->fieldDefinition->getName() . '_remove_') === 0) { |
| 629 |
|
$parents = array_merge(array_slice($trigger['#parents'], 0, -static::$deleteDepth), ['target_id']); |
| 630 |
|
} |
| 631 |
|
|
| 632 |
|
if (isset($parents) && $value = $form_state->getValue($parents)) { |
| 633 |
|
$entities = EntityBrowserElement::processEntityIds($value); |