I am new to the module. Not sure how it is supposed to work. I created a Field Collection which appears in the node.

When I click Add another item this error occurs. Have tried with both Beta2 and Development version:

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /system/ajax
StatusText: n/a
ResponseText: 
Fatal error:  Call to undefined function node_form_validate() in /includes/form.inc on line 1414
ReadyState: undefined
CommentFileSizeAuthor
#29 added_items.png6.66 KBjmuzz
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

blainelang’s picture

I can confirm this error and have a collection on one content type (created first) and that works fine - able to add another instance. For a 2nd content type, it's not working and have removed a couple of the fields in the collection as a test - no change. Not sure if having more then one collection is a factor but they are on different content types.

A bit more troubleshooting and I'm on the trail but don't have a solution/fix. If I add the 2nd content type using node/add/content_type -- all is good.

In my case, I am using a function off a menu handler to accomplish this and my function is below. I have included what I believe are the required includes and node_form_validate is in node.pages.inc and is being included. As a test, I copied the function node_form_validate into my module and now, when I click on Add Another the form goes further but then errors out on other issues.

function recast_add_request($node) {
  global $user;

  if( !function_exists("node_form")) {
    module_load_include('inc', 'node', 'node.pages');
  }

  if( !function_exists("field_collection_item_form_validate")) {
    module_load_include('inc', 'field_collection', 'field_collection.pages');
  }

  $node = new StdClass();
  $node->uid = $user->uid;
  $node->name = $user->name;
  $node->type = 'recast_request';
  $node->language = '';
  node_object_prepare($node);

  $form = drupal_get_form('recast_request_node_form', $node);

  $output = drupal_render($form);
  return $output;

}
blainelang’s picture

Category: support » bug
blainelang’s picture

Update: On the same form, I had a need to use the #AJAX formapi feature and it also triggered the same undefined function error.

Adding require_once(DRUPAL_ROOT . "/modules/node/node.pages.inc"); at the top of the module solved the issue, but as noted in http://drupal.org/node/921398#comment-3995822, using form_load_include() in the HOOK_form_alter is a better option.

function mymodule_form_{form_id}_form_alter(&$form, &$form_state, $form_id) {

  form_load_include($form_state, 'inc', 'node', 'node.pages');

   ....

}
dmadruga’s picture

I experienced an almost identical issue (Fatal error: Call to undefined function field_collection_item_form_validate in /includes/form.inc on line 1460).

Workaround: Implementing hook_form_alter on a custom module.

function mymodule_form_field_collection_item_form_alter(&$form, &$form_state, $form_id) {
form_load_include($form_state, 'inc', 'field_collection', 'field_collection.pages');
}

monsoon’s picture

Hi,

I am encountering similar error. I created a field collection of two fields in a registration form where a language Interpreter has to submit language combinations he can interpret. I am using term reference twice for same taxonomy i.e. Languages (Languages: is a vocabulary which contains all the world languages as terms.). Therefore field collection has two fields in the field collection along with two buttons, as follows:

1. Language you can interpret from (combo box of the world languages)
2. Language You can interpret to (combo box of the world languages)
[remove button] [add another item button]

Field collection appeared to be a good solution to above problem but encounters an ajax error. If you have an alternative solution, please recommend that. Since this is vital part of my Profile2 user registration form.

Thanks.

Please check the following error message.

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /field_collection/ajax
StatusText: n/a
ResponseText:
Error
The website encountered an unexpected error. Please try again later.

ReadyState: undefined

Itangalo’s picture

Are you using Field Collection Table? If so, this might be a duplicate of #1880858: Add Another Item produces JS error and completely breaks tabledragging.

pixel8r’s picture

Here is my Ajax error when clicking add more:

An AJAX HTTP error occurred.
HTTP Result Code: 503
Debugging information follows.
Path: /site.com/field_collection/ajax
StatusText: Service Temporarily Unavailable
ResponseText:
503 Service Temporarily Unavailable
Service Temporarily Unavailable
The server is temporarily unable to service your
request due to maintenance downtime or capacity
problems. Please try again later.

This error occurs on node edit screen when trying to load another set of field collection.
To solve this issue, I had to install Token Tweaks module and modify token depth. Also had to modify php.ini max_input_vars to a much higher number. Important: be careful when modifying token depth, especially if you are using tokens deeper than first level for url paths, folder names etc. If you set token depth to 1 it will break your other tokens.

I don't remember having this issue with FC before. But since the File Entity update FC is throwing errors.

Modules used (related to this):

Drupal 7.22
Field collection 7.x-1.0-beta4+14-dev
File entity 7.x-2.0-unstable7+72-dev
Entity API 7.x-1.0-rc3+11-dev
Entity tokens 7.x-1.0-rc3+11-dev
Token 7.x-1.5

NancyDru’s picture

@monsoon and @pixel8r: Those seem to be different issues and should be in a separate issue. This issue should focus on "Call to undefined function node_form_validate()".

I am not using File Entity, so that is not in play here. I do have Field_Collection_Table and the JS issues with that don't seem to be the problem, but I will disable it just to see. Even with FCT disabled, I get this problem. I also have several Computed Fields within the collection.

david_garcia’s picture

Suscribing

jlporter’s picture

As described by #3
Adding require_once(DRUPAL_ROOT . "/modules/node/node.pages.inc"); at the top of the module solved the issue.

This was with a field collection when the less privileged user would click add another. For some reason it worked as admin user. It may have to do with less privileged user not having overlay. My users are using node clone so it may be that the dependency for node.pages.inc doesn't get pulled in because it's not in a typical node workflow.

NancyDru’s picture

It would be nice if someone could narrow down exactly where to place that. Node.pages.inc exists so that code wouldn't have to be loaded except when needed; always calling it in defeats the performance goal.

sagraham’s picture

I'm seeing a similar issue.

I have a content type which has two field collections.

One of the field collections (call it FC1) has a textfield and text area. The text area has filtered HTML and used CKEditor (via WYSIWYG module).

I can add seven field collections without a problem. When I click 'Add Another Item' to add number eight, I receive this error in a JavaScript dialogue box;

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /system/ajax
StatusText: error
ResponseText:
ReadyState: 0

I get this whether I click on the 'Add another item' for FC1 or FC2 (which is much simpler).

However, if I change the text format from 'Filtered HTML' to 'Plain Text' and CKEditor is removed from the textareas, I can add another item without a problem.

I've tried with CKEditor 3 and 4. Same issue.

I've tried massively upping the memory PHP has, but it makes no difference.

david_garcia’s picture

#3 Working OK.

wonder95’s picture

Issue summary: View changes

I am using the beta7 version (important because I need the Migrate destination handler), and I get this error when attempting to add a second item to a basic collection with the default field_image and two text fields. I upgraded from beta4, and had no issues prior to the upgrade.

wonder95’s picture

In my case, this turned out to be an issue with a custom extension to the Filefield Sources module and an external file not being properly included. Once I resolved that issue, this issue went away.

Anonymous’s picture

First I got this message in Chrome when trying to add another item:
Notice: Undefined offset: 92 in field_collection_field_widget_embed_validate() (line 1675 of /sites/all/modules/field_collection/field_collection.module).

and then when I tried to save I got this:
EntityMalformedException: Missing bundle property on entity of type field_collection_item. in entity_extract_ids() (line 7734 of /includes/common.inc).

I should add that I'm having 92 items in my field collection. When I work in Firefox the browser just freeze.

Anonymous’s picture

Version: 7.x-1.0-beta2 » 7.x-1.0-beta7
Priority: Normal » Critical

Here what my screen looks like.
screenshot
It quite annoying not being able to have multiple field items without the whole thing crashing. Basically I can't work on my website anymore because of this issue.

Anonymous’s picture

A decrease of memory in php.ini did the trick.

jmuzz’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

I noticed there is some talk about a less privileged user being involved and a language interpreter using the form. There are problems with the entity translation and field permissions module when combining them with field collections.

If anybody is seeing this happen in beta7+ without either of these modules please post the result of debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) .

Or if anybody can provide some specific steps to reproduce that would be great.

jmuzz’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
apmsooner’s picture

Version: 7.x-1.0-beta7 » 7.x-1.0-beta8
Status: Closed (cannot reproduce) » Active

Reopening this issue as it is very simple to reproduce:

For my use case, i'm hiding the field collection field in the node and adding an item manually with path:
/field-collection/field-ownership-agreements/add/node/1102?destination=node/1102

I have a multi-valued simple text field in the field collection item set as unlimited. Before saving the field collection item, after clicking 'add another item' on my text field, i get the following error:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /system/ajax
StatusText: OK
ResponseText: Fatal error: Call to undefined function field_collection_item_form_validate() in /srv/bindings/eba708d12fe940fd968019990d5eb953/code/includes/form.inc on line 1513

Now, if i save the field collection item with just one value from my text field and edit the field collection item, i can add unlimited additional values on my text field with no error so the problem appears to be in the validate callback for new items.

Lingaraj_M’s picture

#3 Working OK.

apmsooner’s picture

The hook_form_alter suggested in #4 worked for my issue in #21 but it sounds like #3 and #4 would be needed depending on whether form is embedded in node or as standalone. I'm not sure where code should be added to create a proper patch. This issue still exists for beta9 recent release.

apmsooner’s picture

Version: 7.x-1.0-beta8 » 7.x-1.0-beta9
Priority: Normal » Major

Updating this issue to reflect still a problem in beta9 release and updating priority to Major as unlimited value fields are useless within field collection without a form alter adding the necessary include file.

henryhu’s picture

#3 works for me.

gangu’s picture

Hello,

On drupal 7, I have a problem with a form. Render content type form in drupal 7 everthing working fine but

I created a Field Collection, when I click Add another item
this error occurs

/************Error************/
An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /system/ajax
StatusText: n/a
ResponseText: ShareEmailFacebookTwitterGoogle+PinterestLinkedInStumbleUponRedditGoogle BookmarksWordPressTumblrDeliciousDiggMySpaceYahoo BookmarksBeboMister-WongApp.netWaneloOrkutXINGBufferEvernoteWhatsAppMendeleyPocketVKPinboardSpringpadFlipboardArtoAIMYahoo MessengerPlurkDiasporaBlogger PostTypePad PostBox.netKindle ItBaiduNetlogCiteULikeJumptagsFunPInstapaperPhoneFavsXerpiNetvouzDiigoBibSonomyBlogMarksStartAidKhabbrMeneameYoolinkBookmarks.frTechnotizieNewsVineFriendFeedProtopage BookmarksBlinklistYiGGWebnewsSegnaloPushaYouMobSlashdotFarkAllvoicesJamespotTwiddlaLinkaGoGoNowPublicLiveJournalLinkatopiaBuddyMarksViadeoWistsSiteJotDZoneCare2 NewsBitty BrowserOdnoklassnikiMail.RuSymbaloo FeedsFolkdNewsTrustAmazon Wish ListPrintFriendlyTuentiEmailRediff MyPageGoogle GmailYahoo MailOutlook.comAOL MailAny email    By AddToAny
We Are Working On Riley Drupal
The website encountered an unexpected error. Please try again later.
ReadyState: undefined
/************Error************/

<?php
function customurl_menu() {
   $items = array();
	$items['program/%/register'] = array(
	      'title'            => t('Add @node_type', array('@node_type' => t('Node Type'))),
	      'page callback'    => 'drupal_get_form',
	      'page arguments'   => array('module_node_add_form', 'registration'),
	      'access arguments' => array('administer nodes'),
	      'file path'        => drupal_get_path('module', 'node'),
	      'file'             => 'node.pages.inc',
	      'type'             => MENU_LOCAL_TASK,
	      'weight'           => 1,
	      ); 
	return $items;
}

function module_node_add_form ($form, &$form_state, $node_type) {
	global $user;
	//if( !function_exists("node_form")) {
	module_load_include('inc', 'node', 'node.pages');
	//}
	//if( !function_exists("field_collection_item_form_validate")) {
	module_load_include('inc', 'field_collection', 'field_collection.pages');
	// }
	$node = (object) array(
	'uid' => $user->uid,
	'name' => (isset($user->name) ? $user->name : ''),
	'type' => $node_type,
	'language' => LANGUAGE_NONE,
	);

	node_object_prepare($node);
	$form_state['build_info']['args'] = array($node);
	form_load_include($form_state, 'inc', 'node', 'node.pages');
	$form = drupal_retrieve_form($node_type . '_node_form', $form_state);
	drupal_prepare_form($node_type . '_node_form', $form, $form_state);
	return $form;

}
?>
pipep’s picture

Version: 7.x-1.0-beta9 » 7.x-1.0-beta11
Priority: Major » Critical

This issue makes the site I'm working unusable as all ajax forms are crashing now.

I was using field collection to add data into a table inside a node, and around nº200 everything stopped working.

Nothing seems to work to fix this on my environment.. I'll look for a solution and post it if I do.

EDIT: nothing worked for me on latest versions of everything, so I surrender; maybe on the description you guys should add a note that the module doesn't handle more than 186 items (collection of 3 text fields and 2 integers in my case). Thanks anyway..

riddhi.addweb’s picture

Issue tags: +Field collection
jmuzz’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: -Field collection
FileSize
6.66 KB

I followed the steps described in #21 (though I'm not sure it's really the same issue as everybody else is describing since it's in the field collection item form instead of the host's form) but I was able to add more text field items without any errors (see screenshot).

Can anybody provide steps to reproduce this error from a clean install, or some addition to field_collection.test that illustrates the problem?

jmuzz’s picture

Priority: Critical » Major

If there's anything about it in the watchdog logs or your web server's error logs that could be helpful too.

arnoldbird’s picture

Project: Field collection » Form API
Version: 7.x-1.0-beta11 »
Priority: Major » Normal
Status: Postponed (maintainer needs more info) » Active

This is still an issue in Drupal 7.67. It is not specific to the field_collection module. To get the field working properly, I needed to add a module_load_include to the top of my_module.module, like so...

module_load_include('inc', 'my_module', 'my_module.forms');

Somehow it's not sufficient to reference the my_module.forms.inc file in hook_menu. Not sure if this is a problem with the forms system or the menu system.

DamienMcKenna’s picture

Project: Form API » Drupal core
Version: » 7.x-dev
Component: Code » forms system

Moving to the correct project.