Advertisement
Sadchenko

Placeholder'ы для webform

Aug 17th, 2016
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. function main_form_alter(&$form, &$form_state, $form_id) {
  2.   if ($form_id == 'webform_client_form_2' || $form_id == 'webform_client_form_3' || $form_id == 'webform_client_form_1') { // Пример: "webform_client_form_26"
  3.     foreach ($form["submitted"] as $key => $value) {
  4.       if (in_array($value["#type"], array("textfield", "webform_email", "textarea"))) {
  5.         $form["submitted"][$key]['#attributes']["placeholder"] = t($value["#title"]);
  6.         $form["submitted"][$key]['#attributes']["onfocus"] = "this.placeholder = ''";
  7.         $form["submitted"][$key]['#attributes']["onblur"] = "this.placeholder =" . "'" . t($value["#title"]) . "'";
  8.         $form["submitted"][$key]['#title_display'] = 'invisible';
  9.       }
  10.     }
  11.   }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement