在drupal'默认联系人表单中添加其他字段


Adding additional fields in drupal's default contact form

我正在尝试学习drupal,所以现在我的网站驻留在我的本地主机。我正在使用DRUPAL 7。我用drupal的联系人模块在我的drupal站点上创建了一个联系我们的页面。我想添加一个字段(电话号码)到现有的联系方式,并需要发送的值与电子邮件一起。怎么可能做这样的事。

我在我的联系人模块页面中使用了以下代码

function mymodulename_form_contact_site_form_alter(&$form, &$form_state) {
 $form['phone'] = array(
'#title'    => t('Phone'),
'#type'     => 'textfield',
'#required' => TRUE,
);
$order = array(
'name',
'mail',
'phone',
'subject',
'cid',
'message',
'copy',
'submit'
 );
foreach ($order as $key => $field) {
// Set/Reset the field's 
// weight to the array key value
// from our order array. 
$form[$field]['#weight'] = $key;
}
}

但是该字段没有显示在网站页面上。请帮助。

谢谢

现在一切正常。我已经将代码放在了现有的联系人模块文件中。这就是问题所在。现在我创建一个自定义模块,并将类似的代码放在那里。现在都好了。

唯一需要做的改变就是不再使用

function mymodulename_form_contact_site_form_alter(&$form, &$form_state) {

使用下面的行

function mymodulename_form_contact_site_form_alter(&$form, &$form_state, &$form_id) {