Forms 如何覆盖drupal 7表单API中的默认用户配置文件字段?

Forms 如何覆盖drupal 7表单API中的默认用户配置文件字段?,forms,overriding,drupal-7,user-profile,Forms,Overriding,Drupal 7,User Profile,我想知道如何覆盖/更改用户配置文件中的默认字段,例如:按钮保存、名称、时区等。 我想修改、删除(因为我不需要它们)其中的一些。 要更改用户配置文件,我使用hook:hook\u form\u alter将我自己的字段添加到用户配置文件中。但是现在我想更改默认字段。我该怎么做呢?可以使用钩子表单更改,不过最好使用钩子表单更改 为了能够更改表单,您需要了解数组的结构,最简单的方法是安装Devel模块。然后,您可以通过放置dpm($form)来查看结构在alter函数中 您可以在自定义的模块或主题(在

我想知道如何覆盖/更改用户配置文件中的默认字段,例如:按钮保存、名称、时区等。 我想修改、删除(因为我不需要它们)其中的一些。
要更改用户配置文件,我使用hook:
hook\u form\u alter
将我自己的字段添加到用户配置文件中。但是现在我想更改默认字段。我该怎么做呢?

可以使用
钩子表单更改
,不过最好使用
钩子表单更改

为了能够更改表单,您需要了解数组的结构,最简单的方法是安装Devel模块。然后,您可以通过放置
dpm($form)来查看结构在alter函数中

您可以在自定义的模块主题(在
template.php
文件中)中使用此函数

通常用户配置文件表单id是
用户配置文件表单
。一个简单的例子是:

    function mymodule_form_user_profile_form_alter(&$form,$form_state,$form_id){
      $form['timezone']['#access'] = FALSE; //remove the "timezone" field from the form (default value is still saved)
      $form['field_somefield']['#weight'] = -50; //move the field up
      $form['actions']['submit']['#value'] = t('Add this content now'); //change the submit button text
    }
要获得一个好的教程,请参阅摇篮曲教程(适用于drupal 6,但对d7也是如此!)


API:

可以使用
钩子表单更改
,但最好使用
钩子表单更改

为了能够更改表单,您需要了解数组的结构,最简单的方法是安装Devel模块。然后,您可以通过放置
dpm($form)来查看结构在alter函数中

您可以在自定义的模块主题(在
template.php
文件中)中使用此函数

通常用户配置文件表单id是
用户配置文件表单
。一个简单的例子是:

    function mymodule_form_user_profile_form_alter(&$form,$form_state,$form_id){
      $form['timezone']['#access'] = FALSE; //remove the "timezone" field from the form (default value is still saved)
      $form['field_somefield']['#weight'] = -50; //move the field up
      $form['actions']['submit']['#value'] = t('Add this content now'); //change the submit button text
    }
要获得一个好的教程,请参阅摇篮曲教程(适用于drupal 6,但对d7也是如此!)

API: