I want to prepopulate a node reference field for content_type AAAA, while creating BBBB.

I see following in View Source of add form of BBBB

<div class="form-item">
 <label for="edit-field-aaaa-nids">AAAA: <span class="form-required" title="This field is required.">*</span></label>
 <select name="field_aaaa[nids]" class="form-select required" id="edit-field-aaaa-nids" ><option value="11">aaaa1111</option><option value="22">aaaa2222</option></select>
</div>

I used the following link to prepopulate.. But it didn't work
http://www.mysite.com/?q=node/add/BBBB&edit[field_aaaa][nids]=22

Am i doing something wrong

Comments

websites-development.com’s picture

add the group fieldset, if any
edit[group_name][field_aaaa][nids]=222

gagarine’s picture

Don't work on D6 see http://drupal.org/node/258449

Gerald Mengisen’s picture

As an alternative, you can use the Custom Links module, set up a link with the nid as parameter, and add the following code to your CCK node reference field's PHP default value:

if(arg(1) == 'add'){
  return array(array('nid' => arg(3)));
}else{
  return array(array('nid' => NULL));
};
joachim’s picture

That's a really handy bit of code! It should really go into a handbook page for CCK somewhere!

ferrangil’s picture

Subscribing...

falco8’s picture

subscribing

jbrauer’s picture

Status: Active » Closed (fixed)

Closing issues for unsupported 5.x version