Amazing module by the way!
Right now it does not work with field collections. It needs this exception handling in code as you did with the node and the user form. Or is there another way?

Comments

Artusamak’s picture

Status: Active » Needs work

Thanks for the message. ;)

With is the view / callback that you are building / calling to say that it's not working with field collections?

Artusamak’s picture

Status: Needs work » Closed (cannot reproduce)

Please reopen if you have more information on how to reproduce the issue.

dinesh217’s picture

Hi,
Any alternative solution for views megarow to work with field collection view??

noahott’s picture

Category: Feature request » Support request

I'm struggling with this as well.

I have megarow links set to edit a field collection directly using this path: field-collection/field-my-field/[item_id]/edit
Displaying the form in the megarow works fine, but submitting the form returns HTML resulting in an AJAX error. Some processing of the form by megarow appears to be happening since the form action is modified to /display_megarow/[id]/field-collection/field-my-field/[item_id]/edit

I've also tried to add the #submit handler views_megarow_autoclose_megarow to the form, but it makes no difference.

noahott’s picture

I figured this one out. I needed to override the field_collection form submit callback since the one from the module included a redirect. (field_collection.pages.inc:66)

This is what I added to a custom module to fix the AJAX error:

function my_module_form_alter(&$form, &$form_state, $form_id) {
	// Look for field collection forms
	if ($form_id === 'field_collection_item_form') {
		// override the submit callback
		if (strpos($form['#action'], '/display_megarow/') === 0) {
			$form['#submit'] = array('my_module_field_collection_item_form_submit');
		}
	}
}

function my_module_field_collection_item_form_submit($form, &$form_state) {
	$field_collection_item = field_collection_item_form_submit_build_field_collection($form, $form_state);
	$field_collection_item->save();

        // close the megarow
	$output = views_megarow_command_dismiss($form['#entity']->item_id);
	print ajax_render(array($output));
	drupal_exit();
}

Adding the views_megarow_autoclose_megarow submit callback as an additional callback to field_collection form submit does not work so I had to call views_megarow_command_dismiss() directly.