<img alt="" src="https://secure.agile365enterprise.com/790157.png" style="display:none;">

Developer Tip: Set Webforms Template Programmatically

author
By Team Srijan Oct 15, 2015
Developer Tip: Set Webforms Template Programmatically
Developer Tip: Set Webforms Template Programmatically

This developer tip will help you assign a particular theme for a set of specific webforms.

function MYMODULE_theme($existing, $type, $theme, $path) {
  $webform = array();
  $webform_info = variable_get('MYMODULE_webform_info', array());
  foreach($webform_info as $nid => $data  ) {
    $webform['webform_form_' . $nid] = array(
      'render element' => 'form',
      'template' => 'webform-form-ispace',
      'path' => drupal_get_path('theme', 'MYTHEME') . '/templates',
      'pattern' => 'webform_form_[0-9]+',
    );
  }
  return $webform;
} 
Note: $webform_info = variable_get(‘MYMODULE_webform_info’, array());

 

 

Here we get the list of webforms which needs to have template set.

Template file webform-form-ispace.tpl.php should be placed under the templates folder in the selected theme.

Subscribe to our newsletter