I've read about how to prepopulate the taxonomy field here: https://www.drupal.org/node/228167

On a clean Drupal 7 install (Drupal 7.31) I've installed Prepopulate 7.x-2.0.

Prepopulating the title field works as expected, but I have no luck with taxonomy.

I've verified that there exists a taxonomy vocabulary (named Tags) with a vid=1 in {taxonomy_vocabulary} and that there is a term with the tid=1 in {taxonomy_term_data}.
However, the following URL does not prepopulate the tags taxonomy field:

http://www.example.com/node/add/article?edit[taxonomy][1]=1

There no error message, the taxonomy field ("Tags") is just not prepopulated.

Can anyone show an example URL that works?

Comments

Encarte’s picture

Status: Active » Fixed
gisle’s picture

Status: Fixed » Active

@Encarte - did you test the syntax suggested in the comment you linked on a clean Drupal 7 install?

I've a taxonomy named "tags".

The following URL does not prepopulate the tags taxonomy field:

http://www.example.com/node/add/page?edit[taxonomy][tags][1]=test

There no error message, the taxonomy field ("Tags") is just not prepopulated.

Can anyone show an example URL that works?

mk1000’s picture

This works for me with taxonomy reference field:

Taxonomy fields with widget type taxonomy autocomplete and termname:
http://www.example.com/node/add/node?edit[field_ch_projekt][und]=termname

<input type="text" name="field_ch_projekt_3[und]" id="edit-field-ch-projekt-3-und">

Taxonomy fields with widget type select list and term ID:
http://www.example.com/node/add/node?edit[field_ch_projekt_2][und]=92

<select name="field_ch_projekt_2[und]" id="edit-field-ch-projekt-2-und">

Taxonomy fields with radios and term ID:
http://www.example.com/node/add/node?edit[field_ch_projekt][und][92]=92

<input type="radio" value="92" name="field_ch_projekt[und]" id="edit-field-ch-projekt-und-92">

Taxonomy fields with checkbox and term name or term ID
http://www.example.com/node/add/node?edit[field_ch_projekt][und][92]=92
http://www.example.com/node/add/node?edit[field_ch_projekt][und][92]=ter...

with multiple term IDs
http://www.example.com/node/add/node??edit[field_ch_projekt][und][92]=92...

<input type="checkbox" checked="checked" value="92" name="field_ch_projekt[und][92]" id="edit-field-ch-projekt-und-92">
<input type="checkbox" checked="checked" value="93" name="field_ch_projekt[und][93]" id="edit-field-ch-projekt-und-93">
joetsuihk’s picture

Status: Active » Closed (fixed)

Thanks @mk1000!

I have added your instructions to https://www.drupal.org/node/228167/revisions/view/7786483/7968191, proper credits in log message.

I think this is close case.

Tharick’s picture

#3 works well, thanks for the effort :)

robertgarrigos’s picture

Version: 7.x-2.0 » 7.x-2.1
Status: Closed (fixed) » Active

Taxonomy reference fields doesn't seem to work with 7.x-2.1

Pimmy’s picture

I actually with 7.x-2.1 I cannot prepopulate any filed apart from the title. For example:

Standard text field:

<input type="text" id="edit-field-man-hours-und-0-value" name="field_man_hours[und][0][value]" value="0" size="14" maxlength="12" class="form-text">

http://<site>/node/add/<content_type>?edit[field_man_hours][und][0][value]=9

Node reference:

<input type="text" id="edit-field-project-und-0-nid" name="field_project[und][0][nid]" value="" size="60" class="form-text form-autocomplete" autocomplete="OFF" aria-autocomplete="list">

http://<site>/node/add/<content_type>?edit[field_project][und][0][nid]=75
robertgarrigos’s picture

Pimmy, for the node reference try: http://<site>/node/add/<content_type>?field_project=75It seems this is working this way now for node reference.

Pimmy’s picture

Thanks Robert, but unfortunately it made no difference. I have also tried many other combinations with no success.

robertgarrigos’s picture

Sorry Pimmy. I think that works because I also have the Entity Reference Prepopulate and the Entity Reference Prepopulate Token modules installed. You might give them a try.

clemens.tolboom’s picture

Version: 7.x-2.1 » 7.x-2.0
Status: Active » Closed (fixed)

Let's not distract the developer from #2679839: Container elements and their children cannot be prepopulated in the 7.x-2.1 security update release which blocks lot's of fields from getting pre-populated using 7.x-2.1

@robertgarrigos re-opening an old issue is not 'the right way' as it mostly distract developer.

Pimmy’s picture

I am sorry, but I gave up - Entity Reference might be pre-populating OK, but Node Reference pre-populating isnt working at all for me.

Ended up falling to the Node Reference URL Widget module and it works very nice and straight forward.

robertgarrigos’s picture

@clemens.tolboom I agree. I wasn't aware of that issue.

anybody’s picture

Status: Closed (fixed) » Closed (duplicate)

#11 is correct. I just checked the implementation and that's the reason. #2679839: Container elements and their children cannot be prepopulated in the 7.x-2.1 security update release is the problem behind.

ibraaheem’s picture

I can confirm that this works - &edit[field_name][und][tid]=tid
According to this issue
https://www.drupal.org/project/prepopulate/issues/1772148