why don't set the placeholder attribute for contact field?

101 Views Asked by At

this is my code that use in hook_form_alter function for set the placeholder attribute:

        if ($form_id == 'contact_site_form') {
            $form['name']['#title'] = t('name/family name');
            $form['name']['#attributes']['placeholder'] = t('Enter your name');
        }

why don't set the placeholder attribute for contact field?

1

There are 1 best solutions below

0
On BEST ANSWER

I added this line to code and the problem was solved:

 $form['name']['#default_value'] ='';

Edited code is:

if ($form_id == 'contact_site_form') {
    $form['name']['#title'] = t('name/family name');
    $form['name']['#default_value'] ='';
    $form['name']['#attributes']['placeholder'] = t('Enter your name');
}