When "Add another item" is clicked on a multi field collection table, I get a Javascript error "TypeError: cell[0] is undefined" in line 153 of tabledrag.js. This breaks table dragging and ajax functionality completely.

I can see the problem is that there are missing <tr>s inside <thead>. So far, I have not found a solution. I will post a follow up if I get to the bottom of this.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Nick Robillard’s picture

Title: Add Another Item produces JS error and completely breaks tabledragging » Add Another Item produces js error and breaks tabledrag
Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Status: Active » Closed (won't fix)
Issue tags: -editablefields

This seems to be the fault of Editablefields module.

Nick Robillard’s picture

Title: Add Another Item produces js error and breaks tabledrag » Add Another Item produces js error and breaks tabledrag when using Editablefields formatter
Status: Closed (won't fix) » Active
Issue tags: +editablefields

(Edited to avoid confusion)

Nick Robillard’s picture

Title: Add Another Item produces js error and breaks tabledrag » Add Another Item produces js error and breaks tabledrag when using Editablefields formatter
Status: Active » Closed (works as designed)
Issue tags: +editablefields

Closing.

Nick Robillard’s picture

Title: Add Another Item produces js error and breaks tabledrag when using Editablefields formatter » Add Another Item produces JS error and completely breaks tabledragging
Version: 7.x-1.x-dev » 7.x-1.0-beta1
Status: Closed (works as designed) » Active
FileSize
98.1 KB

And I'm back. :)

I have disabled Editablefields module and I am still getting the aforementioned Javascript error as well as a blank row being inserted when Add Another Item is clicked.

I have tested with both the latest dev versions of Field Collection as well as Field Collection Table. I have also tested with the latest stable versions of both, Field Collection 7.x-1.0-beta5 and Field Collection Table 7.x-1.0-beta1. I am using Entity 7.x-1.0. I have a nearly out of the box Drupal 7.18 setup here. Is no one else seeing this?

Attached is a screenshot of a node edit page. You can see the buggered table row, as well as the tabledrag.js error.

Steps to reproduce:

  1. Install and enable latest stable releases of Field Collection (http://drupal.org/project/field_collection) and Field Collection Table (http://drupal.org/project/field_collection_table) modules.
  2. Create a content type and add a Field Collection field, using Table widget and Unlimited number of values.
  3. Go to /admin/structure/field-collections and add some fields to the field collection.
  4. Go to node add form of content type you just created. Click Add Another Item on the field collection and you will see the described errors. They also manifest on node edit.
Nick Robillard’s picture

Title: Add Another Item produces js error and breaks tabledrag when using Editablefields formatter » Add Another Item produces JS error and completely breaks tabledragging
Version: 7.x-1.x-dev » 7.x-1.0-beta1

Aaaand another update. This issue goes away with Field Collection beta 2 (as this project page says). However, that is really unfortunate, as the latest Field Collection beta 5 has lots of new/improved functionality (like Remove links and revisions). I don't see much action here and deadlines are coming, so I've forked Field Collection beta 2 and will continue to port more recent Field Collection functionality back to beta 2. This sucks because anything I do now is pretty much useless to the community. O well, c'est la vie.

yenidem’s picture

I have same problem, I tried latest dev version but problem has not solved. Please advice.

yenidem’s picture

Nick,
As ı specified at#6 I had same problem. Now, I changed widget type as "embed" and style the fields by CSS, this is works for now. you can try it this solution at this moment.

Nick Robillard’s picture

Sure, Embedded works but I need Tables.

yenidem’s picture

FileSize
76.22 KB

Nick,
OK, we need table as well but see the attached screenshot. I use embedded widget as editing form and I use table format as view.
and please note that divs and spans better than tables. I stylize with css and editing form looking as table, I have not finished styling yet. This is temporary solution until problem solved.

Lynnwood’s picture

yenidem,
I've having the same issue. I'd like to get your css tweaks as temporary fix for issue if you're willing to post them here. Thanks - Lynnwood

Phizes’s picture

I have found field collection table works fine with field collection 7.x-1.0-beta4, I'm not sure if beta4 has new features over beta2 though.

I have the need to fix this, but I am just short on time at the moment.

kris-o3’s picture

also experiencing this issue, both in beta1 and dev versions of field_collection_table...

downgrading to beta4 of field_collection seems to resolve this.

kris-o3’s picture

if you DO downgrade to field_collection beta4, you'll have to make some changes to the database manually...

http://drupal.org/node/1783456#comment-7014142

Itangalo’s picture

Itangalo’s picture

More information:

Field Collection pretty recently added a setting "Hide blank items", which removes the last (empty) field item on multiple-value fields.
This setting is enabled by default, and the setting also causes Field Collection Table to whack out (as described in this issue). At least, disabling this setting made things work just fine for me.

I don't know if the setting accidentally removes things that really should be there, or if Field Collection Table expects things to be in a place where they not always are. So I don't know if this is an issue for Field Collection or Field Collection Table.

I get two error logs when the table fails to add another item:

LOCATION	http://localhost:8888/130125/system/ajax
REFERRER	http://localhost:8888/130125/node/2/edit
MESSAGE	Notice: Undefined index: #bundle in field_collection_table_pre_render_field() (line 219 of /Users/falk/Sites/130125/sites/all/modules/field_collection_table/field_collection_table.module).

and

LOCATION	http://localhost:8888/130125/system/ajax
REFERRER	http://localhost:8888/130125/node/2/edit
MESSAGE	Notice: Undefined index: #entity_type in field_collection_table_pre_render_field() (line 219 of /Users/falk/Sites/130125/sites/all/modules/field_collection_table/field_collection_table.module).

I hope this can help to shed some light on the issue.

Itangalo’s picture

(stupid double-post, sorry)

yogaf’s picture

Thanks Itangalo,
Un-checking "Hide blank items" fixed things for me.

Phizes’s picture

I think this may be a duplicate: #1815496: Using "Hide blank items" leads to misformed tables

Using field_collection_table-7.x-1.0-beta1 and field_collection-7.x-1.0-beta5: I copied field_collection_field_attach_form() into a miscellaneous module, and renamed it, and changed 'field_collection_embed' to 'field_collection_table'. This is as mentioned in the above issue, not clean, but by being in a seperate module it does avoid hacking field_collection_table for now.

We were already using a workaround for the addition of empty elements, so it actually turned out cleaner for us to leave it enabled and do this instead.

RossP-1’s picture

Thank you yogaf. I went to structure->content types->MYTYPE->manage fields->edit on MY_FIELD_COLLECTION and unchecked "Hide blank items" in the field settings at the bottom of the page. The misformatting and errors that occured when adding new rows to add content in field collection tables went away. You really made my day!

capellic’s picture

So then this is a Field Collection problem and not a Field Collection Table problem, right? Thanks to post #15 above for the tip I needed. I can confirm that unchecking "Hide blank items" resolves the problem-- but of course now I have an empty field collection row on my nodes forms. And why doesn't there seem to a be case for this in the Field Collection module issue queue?

rooby’s picture

Issue tags: -editablefields

Removing tag - it is not related to editable fields as I am not using it and have the problem.

FiNeX’s picture

I also confirm the bug. It is not related to editable fields.

braindrift’s picture

I have the same issue without using editable fields. Problem seems only to appear if "Hide blank items" is enabled in field settings.

Linked25’s picture

yenidem,

Would you mind horribly posting your css so we can use your fix? I tried recreating what you have and haven't had much luck with it.

Phizes’s picture

Status: Active » Closed (duplicate)
Phizes’s picture

Issue summary: View changes

updating description