Drupal 7 为什么不为联系人字段设置占位符属性?

Drupal 7 为什么不为联系人字段设置占位符属性?,drupal-7,drupal-hooks,form-api,Drupal 7,Drupal Hooks,Form Api,这是我在hook\u form\u alter函数中用于设置占位符属性的代码: if ($form_id == 'contact_site_form') { $form['name']['#title'] = t('name/family name'); $form['name']['#attributes']['placeholder'] = t('Enter your name'); } 为什么不为联系人字段设

这是我在hook\u form\u alter函数中用于设置占位符属性的代码:

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

为什么不为联系人字段设置占位符属性?

我在代码中添加了这一行,问题得到了解决:

 $form['name']['#default_value'] ='';
编辑的代码是:

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');
}