1

I'm trying to add a new component or populate an existing hidden component on a web form programmatically. I found this:

http://drupalcontrib.org/api/drupal/contributions!webform!webform.module/function/_webform_client_form_add_component/6

However I have not found any hooks, which would be the preferred way to do this. I'm essentially just checking to see if there is a hook or how to access that function in a custom module if no hook exists.

0

A webform is simply a node so the rough process of doing this would be to node_load() your particular node, add your components array to the $node->components[] array and then execute a node_save(). There is some documentation here that fleshes out how to programmatically add a webform, your code would look something like this:

$node = node_load(YOUR NODE ID);
$components = $components = array(); #YOUR COMPONENTS ARRAY
$node->webform = array(
      'components' => $components,
);
node_save($node);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.