Prepopulate a taxonomy field - not working?
ronoxQ - January 29, 2007 - 00:43
| Project: | Prepopulate |
| Version: | 5.x-1.2 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
How do I set up a link that automatically adds a certain value to a taxonomy field? Thanks in advance.

#1
For a freetagging vocabulary, I use a link like:
http://drupal5.example.com/node/add/story?edit[taxonomy][tags][1]=sample
Take a look at the page's source code to see what the actual edit variable should be.
#2
Great module! It has a huge positive effect on usability of a site.
In my case it works with
node/add/cckeventsession?edit[taxonomy][3]=60
to preselect term 60.
Can I also preselect more than one term? How would I notate this?
http://icad.devseed.org/en/node/add/cckeventsession?edit[taxonomy][3]=60,61
does not work.
#3
I may be mistaken, but at present I don't think selecting multiple terms is possible with prepopulate. There is a patch that addresses this issue at http://drupal.org/node/81756 , though the syntax required to select multiple terms is not as neat as the one you tried.
#4
I am using the Taxonomy Super Select module for 5.0 and since it creates seperate checkboxes. It appears to work with the following syntax, but only for the highest level terms. Any term that is in a collapsed level will not be found.
edit[taxonomy][1][69]=69 works, but only for the top level terms. I can't figure out why though since the form objects are all structured the same. Could that they reside in nested fieldsets be messing it up?
#5
I'm having troubles getting prepopulate to work with any kind of taxonomy fields. Can anybody confirm they have this problem too using the latest prepopulate.module version?
#6
I can confirm that the latest version works as described above.
#7
Syntax such as:
node/add/image?edit[taxonomy][1]=14
is working for me too. However, I don't use taxonomy super select.
While I'm here: applying http://drupal.org/files/issues/numeric-array-3.patch at http://drupal.org/node/81756 should allow the simpler syntax for multiple select suggested by #2 on this thread:
http://icad.devseed.org/en/node/add/cckeventsession?edit[taxonomy][3]=60,61
This patch still needs to be tested by someone apart from me.
#8
Hmm... okay, if it works for you guys at least htat gives me some hope.
I think I remember seeing something, somewhere around here, about locale.module and/or image.module or whatever handling the forms *after* prepopulate did its magic, and thereby undoing the "prepopulating"? Anybody got any extra info? Gonna try turning those off and see if prepopulate works with the taxonomy.
#9
Damn, no luck, not even turning off locale.module and image.module. I can get the title and the body preopulation to work as usual, but not any of the taxonomy fields, which are exactly the ones I'd like to fill in. :(
#10
Hello ricmadeira,
I expect you have got your URL right but just to check, does the bit after the "edit" in the URL match the name of the "select" tag? E.g. the "taxonomy[1]" in the URL below:
http://www.example.com/node/add/image?edit[taxonomy][1]=11
matches with the "taxonomy[1]" in the name attribute of the select tag in the page you are trying to prepopulate:
<select name="taxonomy[1]" class="form-select required" id="edit-taxonomy-1" ><option value="">- Please choose -</option><option value="11">2006</option><option value="12">-Christmas 2006</option><option value="1">-Easter 2006</option></select>#11
I have this one category:
<select name="taxonomy[13][]" multiple="multiple" class="form-select" id="edit-taxonomy-13" size="4"><option value="">- None -</option>
<option value="126">RPG</option>
<option value="127">Boardgames</option>
<option value="454">Wargames</option>
</select>
I tried with ?edit[taxonomy][13]=126 and ?edit[taxonomy][13][]=126 and no luck. I don't even know why that [] is part of the select name, maybe it's got something to do with my problem?
Then I have two different free tagging categories, set up the same. Here's one:
<div class="form-item"><label for="edit-taxonomy-tags-6">RPGs: </label>
<input type="text" maxlength="255" name="taxonomy[tags][6]" id="edit-taxonomy-tags-6" size="60" value="" class="form-text form-autocomplete" />
<div class="description">blah, blah</div>
</div>
<input class="autocomplete" type="hidden" id="edit-taxonomy-tags-6-autocomplete" value="http://www.(#mysite#).com/taxonomy/autocomplete/6" disabled="disabled" />
<div class="form-item">
?edit[taxonomy][tags][6]=sample got me nothing too.
Well, I'll try to run tests with some simple test category, with no multiple values allowed, no hierarchy, etc. And if that fails, I'll try with a new Drupal instalation.
#12
@ricmadeira, any luck? Plain taxonomy is working for me.
#13
Closing. No response in over 6 weeks.