组中的 drupal 7 form_alter 配置文件字段

标签 drupal drupal-7 drupal-forms

如何访问用户个人资料表单上字段组内的字段?
在我的自定义模块中,我可以使用下面的代码毫无问题地修改帐户名和电子邮件。

$form['account']['name']['#description'] = 'Enter a username';
$form['account']['mail']['#description'] = 'Enter a valid email address';

这不适用于修改个人信息字段组内的字段:

$form['Personal information']['profile_name']['#description'] = 'Enter a valid email address';

下面是我尝试访问的数组部分。

[Personal information] => Array
    (
        [#type] => fieldset
        [#title] => Personal information
        [#weight] => 1
        [profile_name] => Array
            (
                [#type] => textfield
                [#title] => First name
                [#default_value] => 
                [#maxlength] => 255
                [#description] => Enter your first name. The content of this field is kept private and will not be shown publicly.
                [#required] => 1
                [#input] => 1

最佳答案

我认为如果您必须在 $form 对象中找到“已提交”数组并更改其中的数据。

例如:

$form['account']['mail']['#description'] = 'Enter a valid email address';

做到这一点(在我的例子中):

$form['submitted']['account']['mail']['#description'] = 'Enter a valid email address';

关于组中的 drupal 7 form_alter 配置文件字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19841503/

相关文章:

javascript - 使用 jQuery 从日期字符串中删除日期

php - 如何以编程方式禁用和卸载 Drupal 模块?

php - Drupal 7 hook_node_view 添加一个表单到一个节点的内容

php - Drupal 网站被黑了,但找不到源代码?

drupal - 删除在 drupal 中验证失败的表单元素上的红色轮廓

php - Drupal 7 Forms API 条件逻辑在 IE 中不起作用

ubuntu - 用于 Ubuntu 的 Acquia Drupal

php - 将 drupal 站点从 Windows 迁移到 Linux 计算机

drupal-7 - 如何修改 Drupal 的管理屏幕?

drupal-forms - Drupal 8、如何构建分层表单?