Error message missing format

Created on 25 June 2013, over 11 years ago
Updated 22 January 2024, 10 months ago

After a clean install without setting any further formats the system throughs the following error message when saving the node:

Notice: Undefined index: format in image_field_caption_widget_process() (line 128 of /sites/all/modules/image_field_caption/image_field_caption.module).

The message results of the missing "format" key. A fix could look like this:

function image_field_caption_widget_process($element, &$form_state, $form) {
  $item = $element['#value'];

  $has_caption =  isset($item['image_field_caption']) && is_array($item['image_field_caption']);
  
  // Add the additional alt and title fields.
  $element['image_field_caption'] = array(
    '#title' => t('Caption'),
    '#type' => 'text_format',
    '#default_value' => $has_caption ? $item['image_field_caption']['value'] : '',
    '#access' => (bool) $item['fid'],
    '#format' => $has_caption && isset($item['image_field_caption']['format']) ? $item['image_field_caption']['format'] : NULL,
  );

  return $element;
}
🐛 Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

🇩🇪Germany codewhisper

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024