How to programmatically display a webform in a block based on user selection I am developing a module which generates custom blocks based on some configuration done by site admins in a module-specific config page. For each block I would like the admins to be able to nominate a webform (from a select dropdown), which would then be displayed in the block. 

What I don't understand is how to match up the webform selection process with the webform display process. In the module-specific config page, I would generate the options by querying the node table for all nodes of type 'webform', display the titles of the webforms in the select element, and then save the nid of the chosen webform.

However this nid doesn't seem to be much help to me when it comes to my_module_block_view, where (as I understand it) in order to display a webform I need to do something like 

$block['content'] = module_invoke('webform','block_view','client-block-N');


where N is the nid of the node to which the webform is attached, NOT the nid of the webform itself ? Incorrect statement - see correction below

So I'm unsure how to request the webform that the users have selected, as all I know about it is its nid?

What I'm seeing:

On my test Drupal, I have a webform with nid = 1, and content items of nid 2 and 3. Whether I specify 'client-block-1','client-block-1', or 'client-block-3' in my call to module_invoke, I am seeing no webform displayed. 

Does anyone have any suggestions how I should proceed with this?

All help greatly appreciated. 

CORRECTION

In the code example above, N should be the node id of the webform.
You're very close - the return from hook_block_view() is an array with keys content and optionally subject. Your current code example:

$block['content'] = module_invoke('webform','block_view','client-block-N');


Produces the equivalent of:

$block['content'] = array(
  'subject' =&gt; ...,
  'content' =&gt; ...,
);


When you put that through drupal_render(), it gets angry (because subject isn't a render array but isn't prefixed by #).

You're probably looking for:

$block = module_invoke('webform','block_view','client-block-N');


Or simply:

return module_invoke('webform','block_view','client-block-N');


(once N is substituted for the node ID of the webform).