[support] how to associate a node/add form to the node in the URL/loaded?

sebastian inforazor at gmail.com
Tue Sep 25 23:28:37 UTC 2012


okay never mind I found it, it wanted the node title instead of it's 
actual nid (a bit weird if you ask me...? doesn't sound like it should 
load it by its title but by it's NID! but it does works)

$nodeRef = node_load(dpm(arg(1)));

$theForm['field_corresponding_project']['und']['0']['nid']['#value'] = 
$nodeRef->title;

byea yawl!

On 2012-09-25 4:09 PM, sebastian wrote:
> Hello,
>
> I have a node/add form for a Task node that is loading in a block.
>
> The Task needs to have a node-references automatically made for it (the
> user shouldn't see it or be able to alter it) that attaches (points) to
> the node which is being primarily displayed.
>
> So if you are on a Project page, you have the block for add task on the
> left, and I want this task to point to the Project node. The node is
> loaded and also in the URL path.
>
> The block that loads the add/Task does:
>
> <?php $form = node_add('project_task'); ?>
>
> Which $form variable do I set in the node/add form to have this default
> correctly?
>
> I see the variable in the form for the CCK field, just need to know how
> to associate it... #nid to set? #default_value? I tried #default_value
> but this doesn't seem to pass forward when rendered.
>
> Thanks for your guidance!
>
> Kindly,
>
> Sebastian.
>
>
>


More information about the support mailing list