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


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.

1 Answer 1


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,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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