Just a heads up..

I was testing the https://drupal.org/project/paragraphs module with https://drupal.org/project/scald_galaxy on simplytest.me and I noticed this error after saving a node that included a paragraph bundle field that has an included long text / textarea field. I see the error only if that field includes an embedded atom (image) in that textarea field.

Steps to reproduce:
- Create a paragraph bundle (called Rich Text)
- Add a field type long text / text area called main-text.
- Make sure DND is enabled for that field
- Add a "Paragraph" field to the Article content type called "inlines" and check the box to include/use the new Rich Text
- Create an article node.
- Create a new paragraph of type "Rich Text" and drag and drop an atom inside the wysiwyg editor.
- After Saving the node you see the error.

Notice: Undefined index: field_text in dnd_process_textarea() (line 77 of /home/sb01415a6be091fa/www/profiles/scald_galaxy/modules/scald/modules/library/dnd/dnd.module).

Note: the atom still displays correctly on the article node.

Just thought I would let someone know in case it is an easy fix.

Comments

gmclelland’s picture

Status: Active » Needs review
StatusFileSize
new872 bytes

This seemed to fix the problem for me.

Status: Needs review » Needs work

The last submitted patch, 1: fix-undefined-index-notice-2166119.patch, failed testing.

gmclelland’s picture

Um.. Not sure what that test failure is about? Looks like the testbot may be malfunctioning.

DeFr’s picture

Status: Needs work » Needs review
DeFr’s picture

Status: Needs review » Needs work

The original failure was probably a testbot problem, so I've queued the patch for retesting.

That being said, now that I've actually looked into it, this definitely needs work, because it's going to break the "per field default context" feature; you'd need

$settings = isset($form_state['field'][$element['#field_name']][$element['#language']]['instance']['settings']) ? $form_state['field'][$element['#field_name']][$element['#language']]['instance']['settings'] : array();

instead of just

$settings = isset($form_state['field'][$element['#field_name']][$element['#language']]['instance']['settings']);
gmclelland’s picture

StatusFileSize
new977 bytes

Thanks @DeFr - Here is a new patch based on your recommendations.

gmclelland’s picture

Status: Needs work » Needs review

Changing back to NR

gmclelland’s picture

FYI...It is still a problem in Scald 1.2. I just tested the patch in #6 again with Scald 1.2 and it still fixes the problem.

jcisio’s picture

Status: Needs review » Fixed

Committed a simplified version. Thanks.

  • Commit 8d88500 on 7.x-1.x by jcisio:
    Issue #2166119 by gmclelland: Fixed Undefined index notice when using...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

freblasty’s picture

Why not retrieve the field instance based on the element instead of suppressing the error?

function dnd_process_textarea($element, $form_state) {
  if (!empty($element['#dnd-enabled'])) {
    $element['#attached']['library'][] = array('dnd', 'library');
    $instance = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
    $context_default = isset($instance['settings']['context_default']) ? $instance['settings']['context_default'] : variable_get('dnd_context_default', 'sdl_editor_representation');
    $element['#attributes']['data-dnd-context'][] = $context_default;
  }

  return $element;
}