css - How do I tie a Drupal template to a webform with multiple environments? -


disclaimer: inherited drupal 7.44 site no experience in drupal @ all.

the business trying make new webform , want existing one. after looking around found webform has template tied it. docs seems i'm supposed create more template files format webform-form-[nid].tpl.php [nid] webform node id.

we have multiple environments changes must go through - dev, test, , prod. wouldn't node id different in every environment newly created webforms? also, if want apply same template multiple webforms, need make multiple identical template files?

i found css styling existing webform , looks .webform-client-form-25 button.webform-submit , such. 25 node id. have little css experience, feels bad. don't want copy blocks of css, changing node ids on , over. what's proper way assign generic, reusable css classes webforms? saw "custom classes" under "manage display" when editing form, didn't seem change actual html of form. on right track though, should read docs it?

you absolutely right, these detailed selectors not make sense reusable layouts.

each webform html form gets default class of .webform-client-form (that's generic) , id including webform's nid #webform-client-form-<nid>.

so, change #webform-client-form-25 class mentioned above. please aware, affect all webforms then.

to set layout settings several, not webforms, need give these webforms class distinguish them rest. sadly, webform module doesn't provide option that, can add form alter hook in theme's template.php:

function mytheme_form_alter(&$form, &$form_state, $form_id) {   $affected_forms = array('webform_client_form_25', 'webform_client_form_37', [...]);   if (in_array($form_id, $affected_forms)) {     $form['#attributes']['class'][] = 'my-custom-class';   } } 

with .my-custom-class can define css group of webform forms listed in $affected_forms.

as template files, webform states:

this file may renamed "webform-form-[nid].tpl.php" target specific webform on site. or can leave "webform-form.tpl.php" affect webforms on site.

so, again, doesn't provide option out-of-the-box, can create theme suggestions in template.php extending $vars['theme_hook_suggestions'] in page preprocess function.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -