I want my users to create referencing nodes only from referenced nodes pages using links and once created this reference can't be edited. I thought "Leave blank" fallback behavior with "Use fallback behavior when editing content" checkbox set suits well for it but it fallbacks to autocomplete widget so naming it "leave blank" is nonsense. :-)
As i think there needs to be two separated fallback settings - for new and for edited nodes. Jast as a temporary solution a suggest the following patch dealing with "leave blank" issue.
ps: This module is awesome! :-)
--- nodereference_url.module.orig 2011-08-23 00:12:41.000000000 +0400
+++ nodereference_url.module 2011-08-23 11:37:21.000000000 +0400
@@ -394,7 +394,7 @@
if (empty($referenced_nid) || (!empty($field['widget']['edit_fallback']) && !empty($items))) {
// If not on a node/add page (such as editing a node that does not yet have
// a reference), switch to using an autocomplete widget.
- if (in_array($fallback, array('page_not_found', 'leave_blank')) && nodereference_url_get_nid($field_name) === FALSE) {
+ if (in_array($fallback, array('page_not_found')) && nodereference_url_get_nid($field_name) === FALSE) {
$fallback = 'autocomplete';
}
@@ -502,7 +502,7 @@
}
// Arguments must line up exactly if they're not a wildcard.
elseif (arg($part) != $arg) {
- $referenced_nid = FALSE;
+ $referenced_nid = NULL;
break;
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 27-06-2013 11-07-11.jpg | 7.39 KB | romanellom |
Comments
Comment #1
imclean commentedUncheck "Use fallback behavior when editing content" and the field won't be editable once created.
Comment #2
quicksketchThis patch looks like the wrong approach to me. It looks like you're intentionally breaking the way nodereference_url_get_nid() is supposed to work just so that an IF statement would fail.
Comment #3
quicksketchComment #4
quicksketchOkay, reading this post again at least I understand what the request is. The current functionality is "by design" but I agree that it may be less than optimal.
The reason "Leave Blank" option shows the auto-complete widget is that same reason we do it for the "Page not found" option. If you have an option that doesn't allow you input an option on edit, it will be entirely impossible to give that field a value. The assumption the module is working from in this situation is that either you're using Node Reference URL Widget as a convenience tool (rather than some "enforced" system, because it's not really when the user can just change the URL) or that administrators are going to be filling in references that were left blank by the user. In such a situation, the auto-complete widget is the most flexible widget to make available.
Comment #5
romanellom commentedhas anyone found a solution to the edit field?
once set there is no way to edit it or am I wrong?