Hi,

Is it possible to set the form status of a webform within Rules?

I want to open/close a bunch of forms programmatically.

Comments

quicksketch’s picture

Project: Webform » Webform Rules
Version: 7.x-3.13 » 7.x-1.1

You should ask in the Webform Rules module queue. Webform doesn't provide any direct integration with Rules.

stborchert’s picture

Status: Active » Postponed (maintainer needs more info)

I want to open/close a bunch of forms programmatically.

What do you mean with this sentence? Do you want to publish/unpublish the webform nodes?

Webform Rules gives you the ability to react on webform submission updates (create/update/delete), it does not provide any methods to enable or disable webforms.

Goofy2k’s picture

I want to close the possibility for the user to do further submissions. This can be done by hand via Webform > Form Settings > Status of this form.

This action removes the submission button, but the node itself remains published and accessible as it contains other info for the user.

I already have rules acting on the submissions. Now I want to have a Rules to change the form status.

I would be happy if at least I could do it with some php code in an "Execute custom PHP code" action.

stborchert’s picture

Project: Webform Rules » Rules
Version: 7.x-1.1 » 7.x-2.x-dev
Status: Postponed (maintainer needs more info) » Active

Uhm, ok. Seems, its a support request on Rules itself.

Try to load the webform node in the rule you're executing and print its values with dpm() (module "Devel"). Then it should be possible to modify the node with something like this ("$node" is the loaded webform node):

$node->whateverthestatusfieldofwebformisnamed = 0;
return array('node' => $node);

This should update the node and set the status if the form.

Goofy2k’s picture

Thanks,

It should become something like:

$node->webform['status'] = 0;
return array('node' => $node);

I'll give it a try and report back.

Goofy2k’s picture

This works fine !

Thanks. I can now go on to the next hurdle :-)

stborchert’s picture

Status: Active » Fixed

Great to hear :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mitchell’s picture

Title: Set form status with Rules » Set webform status with Rules
Component: Miscellaneous » Provided Module Integrations

Updated component.