some module reuse form field collection create they have #delta but they dont have #max_delta
so they show message

Notice : Undefined index: #max_delta in field_collection_field_attach_form() (line 1432 in /var/www/drupal/sites/all/modules/contrib/field_collection/field_collection.module).

Notice : Undefined offset: 0 in field_collection_field_attach_form() (line 1439 in /var/www/drupal/sites/all/modules/contrib/field_collection/field_collection.module).

i suggest small patch

CommentFileSizeAuthor
fix_max_delta.patch1.35 KBlazzyvn

Comments

lazzyvn created an issue. See original summary.

tawellman’s picture

Thank you, I had this pop up on a customer's site today and your patch worked perfectly. Because of the situation, I had to manually hack the module file. So can't help with why it "failed to apply". Is this something that may get applied or is it just another reason to look towards upgrading to 8?

ciss’s picture

Looks like #max_delta is only ever set if the widget type is "field_collection_sorter".

renatog’s picture

Status: Active » Reviewed & tested by the community

Really works well

  • RenatoG committed c8eea2e on 7.x-1.x authored by lazzyvn
    Issue #3062479 by lazzyvn, ciss, RenatoG, tawellman: bug  form #...
renatog’s picture

Status: Reviewed & tested by the community » Fixed

Committed to the dev branch.

Thank you all

Status: Fixed » Closed (fixed)

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

ayalsule’s picture

I am still having the issue:

    Notice: Undefined index: #max_delta in field_collection_field_attach_form() (line 1432 of ....../sites/all/modules/field_collection/field_collection.module).
    Notice: Undefined offset: 0 in field_collection_field_attach_form() (line 1439 of /..../sites/all/modules/field_collection/field_collection.module).

I am also using the field collection table module

Error message
Notice: Undefined variable: header in theme_field_collection_table_multiple_value_fields() (line 164 of .../sites/all/modules/field_collection_table/theme/theme.inc).
tritof’s picture

I had the same problem creating new field collections on a site where there were already other ones, I played a bit with the settings and found a way out : selecting the content type > manage fields > change the widget type for the field collection from "sortable only" to "included" ("inclus" in french).
In addition, I looked to the code of the patch and the module, weird thing, the second part of the patch isn't there in my version of the module (7.x-1.1):
+ && !empty($form[$field_name][$element_langcode][0]['#entity'])
Applying this piece helped with the second error message "Notice: Undefined offset: 0 in field_collection_field_attach_form() (line 1439 of /..../sites/all/modules/field_collection/field_collection.module)."