Posted by estimi on February 2, 2011 at 1:27pm
Hey guys,
I'm trying to create a new rule where, depending if a certain content is added, with a certain content type, a new webform is created, with a premade set of fields. Is this possible? Any integration between the modules whatsoever? I could not find anything under the populate field options.
Comments
Same question. If I figure it
Same question. If I figure it out, I'll post back here.
Not that I know of
I haven't seen any Rules integration with Webform that does what you describe, and I know the main maintainer of Webform is rather skeptical of Rules – so I'd be surprised if there are Rules actions for doing this.
It is probably possible to do if you know how to create a webform node programmatically (and don't mind writing a bit of Rules code), but it would definately take some coding.
There are Rules coding tutorials in the learning library linked below, in case you want to go that path. I don't have any links to coding for Webform, though. :-/
Good luck!
//Johan Falk
**
Check out NodeOne's Drupal Learning Library! 190+ screencasts and exercises, for Drupal introduction, advanced configuration, and coding. Creative Commons license!
Creating the webform is a
Creating the webform is a cake walk. Adding Fields to it seems to be the tricky part. The webform is just a node of type webform (or some webform enabled content type). Populatiing it with fields, if I can figure that out, I'd be happy to write a rule module for it ;)
Thanks again Johan :)
Creating a clone of a webform as a rules triggered action
Not sure if this helps, but this is what is working for me... I am basically cloning the webform based on a specific node type being created.... in my case my webform is nid 36 its a complete webform with all the fields that I want my new form to have. If you have more than one content type or form, that you want to spawn a new webform clone for, you can duplicate this rule for each content type.
RULE -- Trigger on create node
Condition node is of type (the content type I want to spawn the form creation)
Action execute PHP
//get the nid from the node that was just saved Rules provides the $node variable for this new content
$nid=$node->nid;
//get the uid from the node that was just saved
$uid=$node->uid;
// load the webform you want to copy by nid, NULL the vid, don't cache
$n=node_load(36,NULL,FALSE); //in my case the nid for my webform is 36
/*
assign a title
I use the nid for the node that was just created
so I can link back to it later based on the node its 'attached' to.
*/
$n->title=$nid;
//assign to node author to be the author of this form
$n->uid=$uid;
//null out the nid so a new node will be created
$n->nid=NULL;
//null out of the vid because this is a unique field
$n->vid=NULL;
//null out the created date so a new created data will be added
$n->created=NULL;
//save the node
node_save($n);
Hope this helps...
Exists in Rules Bonus Pack
There actually is an action for cloning a node in Rules Bonus Pack – combine with actions to set title and author, and you got all of this!
It would be interesting to see actions for adding fields to webforms – if you find a way of doing this it would be awesome to add it to Rules Bonus Pack as well.
Cheers
//Johan Falk
**
Check out NodeOne's Drupal Learning Library! 200+ screencasts and exercises, for Drupal introduction, advanced configuration, and coding. Creative Commons license!