I am cloning a webform, and I would like to change its view mode setting.

I implemented a hook, that is triggered when I click clone,

MYMODULE_clone_node_alter(&$node, $context){
    $node->webform['display'] = 'full';
}

But after a save the value of display is not full, but form only.

Looking at the data of the webform in the $node, there is one $nid, but I do not think it is of the new cloned node (since it was not created yet?). So I am a bit confused on how to go from here?

What options do I have? How would I debug this (new to Drupal)?

Thank you

Comments

Quanti.co’s picture

Basically I am assuming I should somehow trigger a change on the webform_block, but I am not sure how to get it since the node was not created yet?

Quanti.co’s picture

One Idea that I had was to
Call node_save($node);

This will give me the new node nid, cause $node caches. In order to avoid duplicates, since it is not reloading the edit page. I thought I can do the change to the webfrom_block after the save, and at the end redirect the user to the edit page of that node by

    drupal_goto('node/$new_nid/edit');

a) this takes me to the admin/content page and not to the edit page (currently logged in as admin)
b) I am not sure if this is too much of a hack.

Ideas?