Skip to content
Snippets Groups Projects

Issue #3185060: Call to undefined method in images of media field

1 file
+ 1
17
Compare changes
  • Side-by-side
  • Inline
+ 1
17
@@ -5,12 +5,11 @@
* Provides a caption textarea for image fields.
*/
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\image_field_caption\ImageCaptionStorage;
use Drupal\Component\Utility\NestedArray;
// @todo Support for Views, maybe built in in D8?
// @todo Support the revision management.
@@ -45,21 +44,6 @@ function image_field_caption_field_widget_form_alter(&$element, FormStateInterfa
* Custom callback function for the #process of an image field type.
*/
function _image_field_caption_widget_process($element, &$form_state, $form) {
// Get the entity.
$entity = $form_state->getFormObject()->getEntity();
// Get the fields definitions.
$field_definitions = $entity->getFieldDefinitions();
// Get the current field definition.
if (!empty($field_definitions[$element['#field_name']])) {
$field_definition = $field_definitions[$element['#field_name']];
}
elseif (!empty($field_definitions[$element['#field_parents'][0]])) {
$field_definition = $field_definitions[$element['#field_parents'][0]];
}
else {
$field_definition = NULL;
}
// Get the current field values (form state).
$field_values = $form_state->getValues();
// If the field has parents (ex: paragraphs) then get the nested values.
Loading