Would it be possible to populate multiple fields at once? Can the code in the URL be chained someway to reference multiple fields?

Thanks

Comments

kaido.toomingas’s picture

Yes you can. You can (should) use l() function for link creation.

<?php
  echo l(t('Title for add my reference'), 'node/add/nodetype',
    array('query' => array('field_1_name' => 'field_1_value', 'field_2_name' => 'field_2_value'))
  ); ?>
Yuri’s picture

thanks, but sorry I'n not a coder...
I'n currently using the og example which has a block of link that prepopulate new nodes with the og entity reference (audience) from context.
'Inside' each group I have project entities with entity reference fields pointing to that group, and now I want to be able to have a views block that generates links which autopopulate the og reference field AND the project reference field.

How should I use your code in a views block, or better, a views pane?

Thanks!

kaido.toomingas’s picture

If you use views you could overwrite node_id field and create your own urls without coding.
You can rewrite your view output to get urls using tokens.
And the output sould be something like..
<a href=node/add/my_node_type?field_myreferencedfield=[nid_token]&field_name2=field_value2">My link</a>
This works only if clean urls are enabled.