The 'add' button works great! The edit button has a glitch that I found happening all the time, no matter if the node_reference is multivalue or not.

Basically, after adding an author, hitting the edit button to edit the author simply resubmits to the current page with the following error set:

Notice: Undefined index: nid in nodeconnect_add_edit_button_submit() (line 80 of /var/www/html/drupal/sites/all/modules/nodeconnect/nodeconnect.form.inc)

The line in question is 'nid' => $form_state['values'][$field][$language][$key]['nid'],

of

$data = array(
    'form'       => $form,
    'form_state' => $form_state,
    'dest'       => $_GET['q'],
    'field'      => $field,
    'key'        => $key,
    'add_child'  => $form_state['clicked_button']['#add_child'],
    'nid'        => $form_state['values'][$field][$language][$key]['nid'],
  );

in nodeconnect_add_edit_button_submit()

On inspecting $form_state['values'][$field], the data structure I see is:

Array
(
    [und] => Array
        (
            [0] => Array
                (
                    [edit_nodeconnect__field_author_0] => Edit Content
                )

        )

)

There is no 'nid' index in the array. This seems to be left over from some previous code and is preventing proper use of the functionality.

Comments

cntlscrut’s picture

Assigned: Unassigned » cntlscrut
ifux’s picture

StatusFileSize
new874 bytes

had the same problem and found out it's a '#limit_validation_errors' problem
patch bellow. hope could help you.

Merry Christmas to everyone! ;-)

berdir’s picture

Status: Active » Needs work
+++ b/nodeconnect.form.inc	(Arbeitskopie)
@@ -40,7 +40,7 @@
-				'#limit_validation_errors' => array(),
+	'#limit_validation_errors' => array(array($field_name)),

Still a tab instead of spaces here.

+++ b/nodeconnect.form.inc	(Arbeitskopie)
@@ -70,6 +70,8 @@
   $language = $form[$field]['#language'];
+dpm($form_state);
+dpm($form);
   $data = array(

debug calls, should be removed

ifux’s picture

Status: Needs work » Needs review
StatusFileSize
new839 bytes

oops, changed it!

ifux’s picture

StatusFileSize
new1.07 KB

it's friday afternoon and soon christmas so my brain does not work that well ;-)
final patch (hope so!)

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good and confirmed that it works.

Both uses of limit_validations_errors have been adjusted for consistency.

Disclaimer: I'm working together with ifux on this project.

cntlscrut’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Thanks guys!

I was trying some similar solutions, as well.

I'm going to review the patch and ready it for a commit.

oadaeh’s picture

Assigned: cntlscrut » Unassigned
Status: Patch (to be ported) » Reviewed & tested by the community

I also confirm that the patch in comment #5 does fix the problem.

Thanks for saving me from having to figure out what the fix was. :^) I had already determined the cause when I found this issue.

@cntlscrut: the Status of "patch (to be ported)" is only for patches that need to go to a different major version, like from 7.x-1.x to 6.x-1.x. There is no other version to port this patch to, so it stays as "reviewed & tested by the community" until it is either committed or deemed as needing additional work. You are also not the person working on fixing the problem, so you should not assign the issue to yourself. Just FYIs for your future issue work. :^)

cntlscrut’s picture

Status: Reviewed & tested by the community » Fixed

Patch applied to branch 7.x-1.x

Status: Fixed » Closed (fixed)

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

shiraz dindar’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs work

Hiya...

Hate to reopen an old issue but it turns out that the patch here unfixes the fix as provided in https://drupal.org/node/1101868. That is to say, we can again no longer use the nodeconnect add button on required fields.

I believe what is wanted is to go back to "'#limit_validation_errors' => array()" on the add button, and leave the "'#limit_validation_errors' => array(array($field_name))" on the edit button. This takes care of both this issue and the one above (which spawned this issue in the first place). Set as such, I have successfully locally tested both the edit button, and the add button on a required field.

I'd provide a patch except that I have other patches on my node_connect which would make my patch non-applicable here. But I do think it's as simple as above.

Hope this helps someone.

Shiraz

hefox’s picture

Status: Needs work » Fixed

There has been no changes.

I'm closing this and re-opening the other since the regression is of that bug.

Status: Fixed » Closed (fixed)

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