Pages

Wednesday, 13 May 2015

How to alter captcha title in drupal 7

function web_register_form_alter(&$form,&$form_state,$form_id) {
switch($form_id){

case 'webform_client_form_81':     // this is form_id
    //drupal_set_message('<pre>'.print_r($form,TRUE));  
    $form['#after_build'][] = 'captch_title_change';      
 // captch_title_change func is define below, (#after_build) it runs after the form or element is built for display(#pre_render as same as).

$form['#validate'][] = 'webform_client_15_dev_form';
 // webform_client_15_dev_form func is define below, (#validate) it validate the form after submit.
    break;

case 'webform_client_form_65':
    //drupal_set_message('<pre>'.print_r($form,TRUE));
    $form['#after_build'][] = 'captch_title_change_hindi';     // another function define below
break;
}
}
function captch_title_change_hindi($form, &$form_state){
    $form['captcha']['captcha_widgets']['captcha_response']['#title'] ='सत्यापन इमेज';
    return $form;
}

function captch_title_change($form, &$form_state){
    $form['captcha']['captcha_widgets']['captcha_response']['#title'] ='Verification Image';
    return $form;
}

No comments:

Post a Comment