public static function FieldFormatterWithInlineSettings::onFieldNameChange in (Entity Reference) Field Formatters 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/FieldFormatterWithInlineSettings.php \Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldFormatterWithInlineSettings::onFieldNameChange()
- 3.x src/Plugin/Field/FieldFormatter/FieldFormatterWithInlineSettings.php \Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldFormatterWithInlineSettings::onFieldNameChange()
Ajax callback for fields with AJAX callback to update form substructure.
Parameters
array $form: The form.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
Return value
array The replaced form substructure.
File
- src/
Plugin/ Field/ FieldFormatter/ FieldFormatterWithInlineSettings.php, line 163
Class
- FieldFormatterWithInlineSettings
- Plugin implementation of the 'link' formatter.
Namespace
Drupal\field_formatter\Plugin\Field\FieldFormatterCode
public static function onFieldNameChange(array $form, FormStateInterface $form_state) {
$triggeringElement = $form_state
->getTriggeringElement();
// Dynamically return the dependent ajax for elements based on the
// triggering element. This shouldn't be done statically because
// settings forms may be different, e.g. for layout builder, core, ...
if (!empty($triggeringElement['#array_parents'])) {
$subformKeys = $triggeringElement['#array_parents'];
// Remove the triggering element itself:
array_pop($subformKeys);
// Return the subform:
return NestedArray::getValue($form, $subformKeys);
}
}