I tried different syntax, but it doesn't work.

How can I prepopulate the foolowing radio button.

Name of the field: field_test
Values: 0,1

I need a corect syntax of URL for this field. Many Thanks

Comments

naero’s picture

I can confirm that the following works in Drupal 6, but you'll need to try and test in D7:

I figured this out based on ianchan's reply here: from http://drupal.org/node/883980#comment-3419684

Essentially, the breakdown is:

https://example.com/node/add/story?edit[group_name][field_name][value][ABC]=ABC

Replace both "ABC" references with the field's form input value you to use to prepopulate. Took a bit of tinkering for me to figure, but it works. I'll close this issue, but please reopen if you're still having issues. Good luck!

s.Daniel’s picture

For me it was:
&edit[field_output][und][2]=2

The html beeing:

<div id="edit-field-output-und" class="form-radios"><div class="form-item form-type-radio form-item-field-output-und">
 <input type="radio" id="edit-field-output-und-none" name="field_output[und]" value="_none" class="form-radio">  <label class="option" for="edit-field-output-und-none">N/A </label>

</div>
<div class="form-item form-type-radio form-item-field-output-und">
 <input type="radio" id="edit-field-output-und-1" name="field_output[und]" value="1" checked="checked" class="form-radio">  <label class="option" for="edit-field-output-und-1">Dashboard </label>

</div>
<div class="form-item form-type-radio form-item-field-output-und">
 <input type="radio" id="edit-field-output-und-2" name="field_output[und]" value="2" class="form-radio">  <label class="option" for="edit-field-output-und-2">Report </label>

</div>
</div>
sk33lz’s picture

I can confirm that #1 syntax works with the latest Drupal 7 dev release for me as well.

TechNikh’s picture

Status: Active » Reviewed & tested by the community

#1 works with Drupal 7

bisonbleu’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Closed (works as designed)

#2 works for me.

  • Drupal 7.38
  • Prepopulate 7.x-2.0

See the Community Documentation page, under Taxonomy:

Taxonomy fields with radios and term ID:
/node/add/node?edit[field_name][und][92]=92

Where '92' is the term ID.

paultrotter50’s picture

I am still struggling with this. I have a pretty clean drupal7.42 sandbox installation that I'm testing this on. Using prepopulate 7x-2.1.

The radio button group I am trying to target is:

  <div class="form-item form-type-radios form-item-field-exampleselect-und">
  <label for="edit-field-exampleselect-und">exampleselect </label>
 <div id="edit-field-exampleselect-und" class="form-radios"><div class="form-item form-type-radio form-item-field-exampleselect-und">
 <input id="edit-field-exampleselect-und-none" name="field_exampleselect[und]" value="_none" class="form-radio" type="radio">  <label class="option" for="edit-field-exampleselect-und-none">N/A </label>

</div>
<div class="form-item form-type-radio form-item-field-exampleselect-und">
 <input id="edit-field-exampleselect-und-1" name="field_exampleselect[und]" value="1" class="form-radio" type="radio">  <label class="option" for="edit-field-exampleselect-und-1">1 </label>

</div>
<div class="form-item form-type-radio form-item-field-exampleselect-und">
 <input id="edit-field-exampleselect-und-2" name="field_exampleselect[und]" value="2" class="form-radio" type="radio">  <label class="option" for="edit-field-exampleselect-und-2">2 </label>

</div>
<div class="form-item form-type-radio form-item-field-exampleselect-und">
 <input id="edit-field-exampleselect-und-3" name="field_exampleselect[und]" value="3" class="form-radio" type="radio">  <label class="option" for="edit-field-exampleselect-und-3">3 </label>

</div>
</div>
</div>

I have tried what I believe to be the formulas above and all sorts of variations on them. However I still haven't been able to get it to work. Could anyone suggest what I should be doing?

Some example of the things I've been trying are:

<a href="https://localhost/drupal-sandbox/node/add/page?edit[field_exampleselect][und][2]=2">create new page 2</a>
<a href="https://localhost/drupal-sandbox/node/add/page?edit[field_exampleselect][und]=2">create new page 2.5</a>
<a href="https://localhost/drupal-sandbox/node/add/page?edit[edit-field-exampleselect-und][field_exampleselect][und]=2">create new page 3</a>
<a href="https://localhost/drupal-sandbox/node/add/page?edit[edit-field-exampleselect-und][field_exampleselect][value][2]=2">create new page 4</a>

I have also added a radio button group called 'output' with 'Dashboard' and 'Report' as the options so that my code matches #2, but even after doing this the following link doesn't prepopulate the field:
<a href="https://localhost/drupal-sandbox/node/add/page?edit[field_output][und][2]=2">create new page radio2 no1</a>

paultrotter50’s picture

Status: Closed (works as designed) » Active

Reopening as cannot get to work with the supplied code. Has something changed since the issue was opened?

bisonbleu’s picture