Hello

I am trying to populate a radio button cck field from a url. Can someone give me a hand to understand the proper url syntax?

The following is the javascript code snippet that I am trying to use:

var url = '/node/add/idea?edit[title]=' + ideaTitle + '&field_ideacategory[value]=' + ideaCategory;

window.location= url;

Comments

gsvitak’s picture

Hello

I figured out the url

node/add/idea?edit[title]=test test&edit[field_ideacategory][value]=Healthcare&edit[taxonomy][tags][3]=healthcare

gsvitak’s picture

Status: Active » Closed (fixed)
alexbk66-’s picture

@gsvitak, can you please provide a bit more info, i.e. which is the radio button field, example HTML.
I can't get 'content taxonomy tree' preselected, see http://drupal.org/node/597610#comment-4315386
Thanks in advance

manuel.adan’s picture

Version: » 6.x-2.2
Status: Closed (fixed) » Active

Same issue here, I have a 4 options radio field, default value is 1 and I try to "prepopulate" for option 3, but it is ignored. This is my query:

/node/NN/edit?edit[field_tipopublicacion][value]=3

and this is my radio field (post-processed by prepopulate):

array (
  '#type' => 'radios',
  '#title' => 'Tipo',
  '#description' => '',
  '#required' => '1',
  '#multiple' => '0',
  '#options' => 
  array (
    0 => 'Texto',
    1 => 'Enlace',
    2 => 'Fichero',
    3 => 'Audio',
  ),
  '#default_value' => '1',
  '#post' => 
  array (
  ),
  '#programmed' => false,
  '#tree' => true,
  '#parents' => 
  array (
    0 => 'field_tipopublicacion',
    1 => 'value',
  ),
  '#array_parents' => 
  array (
    0 => 'field_tipopublicacion',
    1 => 'value',
  ),
  '#weight' => 0,
  '#processed' => true,
  '#attributes' => 
  array (
  ),
  '#input' => true,
  '#process' => 
  array (
    0 => 'expand_radios',
  ),
  '#name' => 'field_tipopublicacion[value]',
  '#id' => 'edit-field-tipopublicacion-value',
  '#value' => '3',
  0 => 
  array (
    '#type' => 'radio',
    '#title' => 'Texto',
    '#return_value' => '0',
    '#default_value' => '1',
    '#attributes' => 
    array (
    ),
    '#parents' => 
    array (
      0 => 'field_tipopublicacion',
      1 => 'value',
    ),
    '#id' => 'edit-field-tipopublicacion-value-0',
    '#ahah' => NULL,
    '#post' => 
    array (
    ),
    '#programmed' => false,
    '#tree' => true,
    '#weight' => 0,
    '#processed' => true,
    '#description' => NULL,
    '#required' => false,
    '#input' => true,
    '#process' => 
    array (
      0 => 'form_expand_ahah',
    ),
    '#name' => 'field_tipopublicacion[value]',
    '#value' => '1',
    '#defaults_loaded' => true,
    '#sorted' => true,
  ),
  1 => 
  array (
    '#type' => 'radio',
    '#title' => 'Enlace',
    '#return_value' => '1',
    '#default_value' => '1',
    '#attributes' => 
    array (
    ),
    '#parents' => 
    array (
      0 => 'field_tipopublicacion',
      1 => 'value',
    ),
    '#id' => 'edit-field-tipopublicacion-value-1',
    '#ahah' => NULL,
    '#post' => 
    array (
    ),
    '#programmed' => false,
    '#tree' => true,
    '#weight' => 0.001,
    '#processed' => true,
    '#description' => NULL,
    '#required' => false,
    '#input' => true,
    '#process' => 
    array (
      0 => 'form_expand_ahah',
    ),
    '#name' => 'field_tipopublicacion[value]',
    '#value' => '1',
    '#defaults_loaded' => true,
    '#sorted' => true,
  ),
  2 => 
  array (
    '#type' => 'radio',
    '#title' => 'Fichero',
    '#return_value' => '2',
    '#default_value' => '1',
    '#attributes' => 
    array (
    ),
    '#parents' => 
    array (
      0 => 'field_tipopublicacion',
      1 => 'value',
    ),
    '#id' => 'edit-field-tipopublicacion-value-2',
    '#ahah' => NULL,
    '#post' => 
    array (
    ),
    '#programmed' => false,
    '#tree' => true,
    '#weight' => 0.002,
    '#processed' => true,
    '#description' => NULL,
    '#required' => false,
    '#input' => true,
    '#process' => 
    array (
      0 => 'form_expand_ahah',
    ),
    '#name' => 'field_tipopublicacion[value]',
    '#value' => '1',
    '#defaults_loaded' => true,
    '#sorted' => true,
  ),
  3 => 
  array (
    '#type' => 'radio',
    '#title' => 'Audio',
    '#return_value' => '3',
    '#default_value' => '1',
    '#attributes' => 
    array (
    ),
    '#parents' => 
    array (
      0 => 'field_tipopublicacion',
      1 => 'value',
    ),
    '#id' => 'edit-field-tipopublicacion-value-3',
    '#ahah' => NULL,
    '#post' => 
    array (
    ),
    '#programmed' => false,
    '#tree' => true,
    '#weight' => 0.003,
    '#processed' => true,
    '#description' => NULL,
    '#required' => false,
    '#input' => true,
    '#process' => 
    array (
      0 => 'form_expand_ahah',
    ),
    '#name' => 'field_tipopublicacion[value]',
    '#value' => '1',
    '#defaults_loaded' => true,
    '#sorted' => true,
  ),
  '#defaults_loaded' => true,
  '#sorted' => true,
)
tezalsec’s picture

+ 1 subscribing

i am having the same problem, prepopulating a value in a 3 option radio field is ignored.
I tried it with both key and label, without success..

Thanks for any help!

crash98’s picture

having the same problem :( Anybody?

naero’s picture

Status: Active » Closed (fixed)

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!