function hook_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'node_form') {
drupal_set_message(t('some message.'));
}
}
You must first bind the keyword to the module keyword. suggests that your module name is "contact_us", then
function contact_us_form_alter(&$form, $form_state, $form_id) {
Now this function has three variables
- $ form
- $ form_id
- $ form_state
The most important variable when changing the form is $ form_id, which basically notes which form is the load on the page.
function contact_us_form_alter(&$form, $form_state, $form_id) {
print_r($form_id);exit;
}
after you find form_id
function contact_us_form_alter(&$form, $form_state, $form_id) {
if($form_id=='contact_us_form')
}
Note: make sure that you have created the user module correctly and enabled it. Also clear the cache
jalil source
share