When you mark a "node reference auto-complete field" as required when you create a node content, The add button can't be used.

The form complain about "xxx field is required." when you click the add button.

Comments

glottus’s picture

Title: The "add a new" button can't be used if the "node reference auto-complete field" is a requiered field » The "add a new" button fails if field is required or has unmatched text

Edited the issue title to include related information.

The green "+ (add new)" button triggers a function that validates the form first, and if that is a required field, it won't accept navigating away while the field is blank.

On the other hand, if a user has entered any text at all, but it hasn't matched an existing node (the very reason to have the "add new" button in the first place), then the function will fail with a warning that "[FIELD NAME]: found no valid post with that title."

The only way to use this "add new" feature at the moment is to have an optional field (not always desireable) AND either get a match on the node title being referenced, OR then clear the field of text used to try and find a matching node to reference THEN click on the "add new" button (not at all obvious to the user and a serious annoyance).

One possible suggestion is the idea presented in #1148236: Embed referred node edit form as a subform of the referring node form? that could be available and collapsed/hidden and triggered upon not finding a match. This would bypass any issues with the timing of validation and present a much smoother transition to the user.

An additional step towards perfection would be to pass the potential title text on to the node/add form called by the "add new" button. At the moment, the user has to enter what they WANT the current node to connect to, then clear that, then enter it again when they get to the proper form.

Of course, in my use case, the original node is an event, referencing a venue node which is mainly just a single array of Location fields. I have the venue node set to auto_nodetitle itself with the Location (name) field content since that would otherwise be basically a duplication right there, so I would need to set that up to properly pull in the suggested title being passed to it and place it in the Location node field rather than the node title field directly, so having it passed as an easily grabbed argument or a token would be great.

guillaumev’s picture

subscribe

Frederic wbase’s picture

subscribe

jdufaur’s picture

subscribe

robcarr’s picture

Priority: Normal » Major

Running 7.x-1.x-dev...

I have same problem occurring for a required field. At the moment, this issue is a complete usability fail, rendering this module - unfortunately - pretty worthless. It's fundamental to the way this module works, as the D6 equivalent (Node Relationships) got around this problem by using a modal popout to populate the new reference.

I think this module's method of caching the parent form has some benefits, but the concept is pretty flawed for more wider use. Somehow, the child node form needs to be a subform within the parent... either #1148236: Embed referred node edit form as a subform of the referring node form? or implementing modal frames within the D7 modal frame mayhem.

geek-merlin’s picture

hey, there is a *cure* for these validation issues, called #limit_validation_errors
we have the same issue over at multistep.module, with a patch that shows how to hack it down: #1065458: Required fields in step >1 break multistep

edit: short version: just set '#limit_validation_errors' => array() in your submit element.

geek-merlin’s picture

geek-merlin’s picture

Status: Active » Needs review
cntlscrut’s picture

Status: Needs review » Fixed

Reviewed and applied suggested changes offered by axel.rutz.

this will address the major issue until a more elegant solution forms.

change applied to 7.x-1.x-dev branch.

Status: Fixed » Closed (fixed)

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

hefox’s picture

Version: 7.x-1.0-alpha1 » 7.x-1.x-dev
Issue summary: View changes
Status: Closed (fixed) » Active

This broke again due to #1359246: Notice: Undefined index: nid in nodeconnect_add_edit_button_submit() according to a comment there, so this needs to be refixed while maintaining the other fix. There is suggestions in the comment left there.