I have a field collection "Entry Information", where the user should be able to add multiple entries before proceeding to the contact information page. The "Add Additional Entry" button works, as does the whole form. However ... the project manager now wishes to hide the previous entry when the "Add Additional Entry" button is clicked. I, and a more knowledgeable Drupal dev, explained that this was a bad idea because 1) it was non-standard Drupal behavior and 2) the user would no longer have the ability to edit or delete the previous entry. Disregarding the advice, I have been ordered to make it so. The problem is that when the new instance of the field collection is added to the form, it is as an unidentified TR table row (i.e, it has classes, but not an ID which specifically identifies the TR).

The first, default, TR has classes "tr .draggable odd drag-previous", the second classes "tr .draggable even", the third classes "tr .draggable odd", the fourth classes "tr .draggable even", and so on.

So, there is no way I can see to write some javascript which would hide the previous rows when a new row is ajax'd into view. (The same PM told me ajax has nothing to do with it, but that is indeed how objects are added to the DOM.)

So, I guess my question is "How do I add an ID to each new field collection row as it is ajax'd into existence?"

Hopefully I can figure out the javascript once that hurdle is cleared ...

Comments

Preston McMurry’s picture

This is from the TD cell contained by the TR which was added. Note the TR has no ID.

td

Attributes
    None

Position
    Left: 162px	Top: 1578px
    Width: 620px	Height: 982px

Other
    Font Family:	Arial,Helvetica,sans-serif
    Font Size:	16px

Ancestors

    html .js wf-prentonultracondensed-n4-active wf-prentonultracondensed-n5-active wf-prentonultracondensed-n7-active wf-active

    body .html not-front logged-in one-sidebar sidebar-first page-node page-node- page-node-19 node-type-page admin-menu

    div #content-container

    div #content .column

    div .main

    div .region region-content

    div #block-formblock-video-entry .block block-formblock contextual-links-region

    div .content

    form #video-entry-node-form .node-form node-video_entry-form

    div

    div .field-group-multipage-group-wrapper field-group-multipage-group group-page-group

    div .multipage-panes multipage-processed

    div #node_video_entry_form_group_page_1 .field-group-multipage group-page-1 required-fields multipage-open form-wrapper multipage-pane

    div .fieldset-wrapper multipage-pane-wrapper

    div #edit-field-entry-list .field-type-field-collection field-name-field-entry-list field-widget-field-collection-embed form-wrapper

    div #field-entry-list-add-more-wrapper

    div .form-item

    table #field-entry-list-values .field-multiple-table sticky-enabled tabledrag-processed tableheader-processed sticky-table

    tbody

tr .draggable even

Children

    div #edit-field-entry-list-und-1-field-title-of-entry .field-type-text field-name-field-title-of-entry field-widget-text-textfield form-wrapper

    div #edit-field-entry-list-und-1-field-url .field-type-text field-name-field-url field-widget-text-textfield form-wrapper

    div #edit-field-entry-list-und-1-field-represented-company .field-type-text field-name-field-represented-company field-widget-text-textfield form-wrapper

    div #edit-field-entry-list-und-1-field-categories .field-type-list-text field-name-field-categories field-widget-options-buttons form-wrapper

    div #edit-field-entry-list-und-1-field-attached-video .field-type-file field-name-field-attached-video field-widget-file-generic form-wrapper

I grepped the project's entire codebase -- included all installed modules, custom or otherwise -- for instances of "

Preston McMurry’s picture

These are the only instances of "<tr" I could find where the TR has classes, and none of them look likely to produce the additional entry:

htdocs/includes/theme.inc:  $output .= ' <tr' . drupal_attributes($attributes) . '>';

htdocs/modules/system/system.admin.inc:  $output .= '<tr class="' . $severity['class'] . ' merge-down"><td class="status-icon">' . $severity['icon'] . '</td><td class="status-title">' . $requirement['title'] . '</td><td class="status-value">' . $requirement['value'] . '</td></tr>';

htdocs/modules/system/system.admin.inc:  $output .= '<tr class="' . $severity['class'] . ' merge-up"><td colspan="3" class="status-description">' . $requirement['description'] . '</td></tr>';

htdocs/modules/system/system.admin.inc:  $output .= '<tr class="' . $severity['class'] . '"><td class="status-icon">' . $severity['icon'] . '</td><td class="status-title">' . $requirement['title'] . '</td><td class="status-value">' . $requirement['value'] . '</td></tr>';

htdocs/sites/all/modules/views/theme/views-view-grid.tpl.php:  <tr class="<?php print $row_classes[$row_number]; ?>">

htdocs/sites/all/modules/views/theme/views-view-table.tpl.php:  <tr class="<?php print implode(' ', $row_classes[$row_count]); ?>">

htdocs/sites/all/modules/ds/modules/ds_extras/ds_extras.panels.inc:  '#prefix' => '<tr class=' . $class . '><td>',