Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Quanti.co on
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
Additional info
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?
More thoughts
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
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?