Is there a way to programmatically add questions to a webform grid? I have seen hooks to use to alter webform options, but not the questions that appear on the left side of a grid.

I would like those questions to be a node titles actually of a content type that I have already defined.

For example, the content type titles will appear on the left and the options are already defined as first choice, second choice, and third choice radio buttons above in the header for each node title.

Here's the grid I would like to produce:

Node Title -- First Choice -- Second Choice -- Third Choice

Title One -- Radio Button -- Radio Button -- Radio Button

Title Two -- Radio Button -- Radio Button -- Radio Button

Title Three -- Radio Button -- Radio Button -- Radio Button

Title n -- Radio Button -- Radio Button -- Radio Button

Essentially I just need a way to import questions that are node titles of another content type into the webform Questions field that requires them to be inputted as pairs ex.

"safe_key|Some readable option"

"safe_key|Some readable option"

"safe_key|Some readable option"

Thank you very much.
Sure enough there is a way, a very neat one, just found it out myself!

In the following example I use a View's result to get the list of nodes I will use as the questions in the webform grid. This allows even easier management of the questions you want to display in your grid, by setting for example specific filters on your view.

You need to implement the hook_webform_component_render_alter hook. Here is the code you need:

function yourmodule_webform_component_render_alter (&amp;$element, &amp;$component) {
  // Select the right webform component
  if( $element['#type'] == 'webform_grid' &amp;&amp; 
      $element['#title'] == 'Title of Webform Component' ) {

    // Override the title of the grid component
    $element['#title'] = "Node Title";
    // and use it as the label of the questions' column
    $element['#title_display'] = "internal";
    $new_grid_questions = array();
    // This is a standard content view that contains at least a nid and a node title field
    foreach( views_get_view_result('my_view', 'my_display') as $res ) {
      $new_grid_questions[$res-&gt;nid] = $res-&gt;node_title;
    }
    $element['#grid_questions'] = $new_grid_questions;
  }
}


And here is a screenshot of the end result:



Hope this helps!