Closed (fixed)
Project:
Prepopulate
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
18 Jan 2009 at 15:53 UTC
Updated:
22 Dec 2010 at 07:41 UTC
Jump to comment: Most recent file
Hi, I've spent hours trying to prepopulate the autocompleting content taxonomy field from this code snippet:
<fieldset class="group-date"><legend>Date</legend><div class="form-item" id="edit-field-reference-date-value-wrapper">
<label for="edit-field-reference-date-value">Date: </label>
<input type="text" maxlength="255" name="field_reference_date[value]" id="edit-field-reference-date-value" size="60" value="" class="form-text form-autocomplete" />
<div class="description">YYYYMMDD</div>
</div>
<input class="autocomplete" type="hidden" id="edit-field-reference-date-value-autocomplete" value="http://vacilando.net/content_taxonomy/autocomplete/field_reference_date" disabled="disabled" /></fieldset>In the prepopulate URL I tried edit[field_reference_date][value], edit[field_reference_date][value][autocomplete], edit[field_reference_date][0], even edit[form_item][field_reference_date][value] (to include the wrapper class ID like it's done with the body tag), etc., etc. and I've read the documentation and tons of forum contributions, but nothing seems to work.
I would appreciate very much your suggestions for the above code, or clear description (or reference to one) of what Prepopulate needs to locate the correct input tag. Thanks!
| Comment | File | Size | Author |
|---|---|---|---|
| #32 | prepopulate.jpg | 12.75 KB | dogboy72 |
| #27 | 360613_prepopulate_27.patch | 2.3 KB | jbrauer |
| #21 | 360613_20100812.patch | 2.3 KB | jmiccolis |
Comments
Comment #1
vacilando commentedFollowing http://drupal.org/node/307669#comment-1043488 I also tried edit[group_date][field_reference_date][value] (where group_group date comes from the fieldset class) -- but without success.
Comment #2
916Designs commentedSo I messed around with things and got lucky. My autocomplete nodereference is set for one content type only, haven't tried multiple.
html of form:
I ended up successfully populating field with this link:
/node/add/member-of?edit[field_mo_faculty_id][0][nid]=97
I created it in the content template for the type of my reference, and thus passed the nid:
$path = $base_url . '/node/add/member-of?edit[field_mo_faculty_id][0][nid]='.$node->nid;So anyway... strange. You would expect to populate field_mo_faculty_id[0][nid][nid] but I only populated field_mo_faculty_id[0][nid], and not with the title of the content, but with its nid.
Comment #3
leoklein commentedJust what I needed. Thanks!
Comment #4
Chris Einkauf commentedA quick note to future readers of this issue: I found that this method only works if your autocomplete node reference field is set to "Autocomplete matching: Starts with" (as opposed to "Autocomplete matching: Contains").
Comment #5
egsj commentedI had Prepopulate successfully filling out a user reference and a node reference field for me but it recently stopped working and I am unsure why. There have been no changes to the field names.
Here is what I have:
name="field_whichjob[0][nid][nid]"
id="edit-field-whichjob-0-nid-nid"
name="field_submitto[0][uid][uid]"
id="edit-field-submitto-0-uid-uid"
and in the URL ?edit[field_whichjob][0][nid]=594&edit[field_submitto][0][uid]=54
I have verified it is not a permissions or view problem as these fields will look up the values if manually entered.
Any help is much appreciated.
Comment #6
egsj commentedThey are in fieldgroups but the previously listed thread did not help, and they were always in fieldgroups.
Comment #7
egsj commentedAny ideas?
Comment #8
egsj commentedHowever,
?edit[field_whichjob][0][nid]=742 did not work.
field is set to "starts with..."
does also find the node when manually typed in.
Comment #9
aren cambre commentedToo many problems above for this not to be a bug.
I can't get edit[field_fieldname][0][nid]=nid to work regardless of autocomplete matching or content type restrictions.
Comment #10
mdroste commented"?edit[field_fieldname][0][nid] = nid" works for me in 6.x-1.1
Nothing works for me in 6.x.2. Not even normal textfields.
Comment #11
clemens.tolboomPlease install devel.module to check field structure instead of dumping html :)
Using http://example.com/node/add/test_node?edit[field_selectbox][0][nid]=5&ed... where there is a _select_ and a _autocomplete_ field.
Both are prepopulated fine on 6.x-1.1
So is this bug about 6.x-1.1 or 6.x-2.x-dev?
Comment #12
aren cambre commentedIt's for 1.1.
I inspected field formats directly through the database to arrive at what I tried in #9. Are you using autocomplete on a node reference?
Comment #13
frankcarey commentedit's not working for me either. one thing to try is edit[field_nodereference][0][nid][nid]. (notice the double [nid])
Comment #14
egsj commentedFixed by this much better module http://drupal.org/project/nodereference_url
Comment #15
frankcarey commentedcorrection ?edit[field_blog_entry][0][nid]=89 works fine for me (it is an autocomplete set to "contains"). my problem was that i forgot to click submit in my modules list, so the module was never enabled :P So it works for me now.
Comment #16
frankcarey commented@ethangj ah, nodereference_url can be a useful module, but it didn't do 2 important things that I needed.
1) It won't let a user edit the node reference after the node is saved (they can't change it later).
2) It doesn't work with multiple entry fields.
Comment #17
clemens.tolboomMaybe "contains" is key ... my node_reference autocomplete has a "contains".
Comment #18
garryi commentedI'm trying to accomplish the same thing, except I want to pass an argument into the field.
Can anyone give me step by step on accomplishing this?
Comment #19
damienmckennaI've gotten it working with both v6.x-1.x and v6.x-2.x:
Comment #20
jmiccolis commentedThis appears to be broken in the 2.0 release. I'm looking into the code now and should be able post back shortly with more details, and hopefully, a patch
Comment #21
jmiccolis commentedThe attached patch seems to fix the issue for me and also moves the all the recursion into the recursive function, instead of having the first iteration out side of it.
One note to noderef users... you'll need to do more than just pass the nid with 2.0 - you need to do at least something like `[nid: 52]`
Comment #22
damienmckennaThis doesn't work either. By the time prepopulate_after_build() runs the data structure has changed completely. I'll work on this later, a site I'm finishing has been using v1.x successfully until now.
Comment #23
Grayside commentedPatch looks good, makes nodereference smooth like butter.
It's important to keep in mind the differences in how this operates:
edit[field_nodereference][0][nid][nid]=[nid: #]If you try to use a title fragment, remember the autocomplete widget will not look up the node unless it gains focus on the page.
And of course, for development purposes you now need to extract the nid from the string.
Comment #24
jbrauer commentedThis seems to work well. I'd like to get a few more reviews and will link this from another issue it fixes.
Re #22 please do not use the insecure version 1.x code on any sites as it leaves them exposed to security issues.
Comment #25
webkenny commented#21 Works for this and for #883980: New field formats are necessary in Prepopulate 6.x-2.x
Comment #26
mikey_p commentedCall-time pass by reference is deprecated.
Comment #27
jbrauer commentedUpdated patch.
Comment #28
pkej commentedThe patch in #27 works well with nodereferences and body textarea, as well as fieldsets and cck fields inside those.
Comment #29
pkej commentedI posted into the thread before refreshing it. I was working with this issue and testing out prepopulate.
Comment #30
jbrauer commentedCommitted to HEAD. New -dev release should be available within 12 hours. If we find no other big bugs a new release will be out this week.
Comment #32
dogboy72 commentedI've got this working fine, but I have a user interface issue. The node reference fills with only the nid (i.e. [nid: 123]) instead of how it works normally. See attached.
I've tried both "starts with" and "contains" for the autocomplete settings. This is perhaps a feature request or a bug. Not sure.
Comment #33
Grayside commentedI suspect that is part of the problem with using #after_build. The nid is being put into place after the form looks up the title and inserts it.
Comment #34
thommyboy commentedso is this a bug? i used prepopulate before to prepopulate a (multivalued) nodereference and it stopped working some time ago.
changing the url helped to fill in the NID but the field only shows "123" instead of "title [123]" and the node does not save.
unfortunately nodereference_by_url does not work for me as it doesn't seem to support multi-valued fields...
Comment #35
Grayside commentedIt's sort of a bug, and sort of a feature request because Prepopulate 2.0 rearchitected its functionality. You need to change the way you craft Prepopulate URLs for node references. See #23.