drupal-8 - hook_form_user_register_form_alter(更改添加的字段)
问题描述
以下内容无效:(#description 和 #attributes 有效。#required 无效)
function bncreports_form_user_register_form_alter(&$form, FormStateInterface $form_state, $form_id)
{
$form['account']['mail']['#attributes'] = ['onblur' => "getElementById('edit-name').value=this.value.toLowerCase();"];
$form['account']['name']['#description'] = 'Use Email address as your username';
$form['account']['name']['#attributes'] = ['onblur' => 'this.value=this.value.toLowerCase();'];
$form['field_district']['widget']['#required'] = true;
}
为什么不?
解决方案
推荐阅读
- bitbucket-pipelines - bitbucket 管道中的 JSON 值替换
- swift - URL 验证发布者
- c++ - Chase-lev deque 中的原子存储
- excel - 将数据框写入现有 Excel 文件中的多个工作表。打开 excel 文件时出现“我们发现 X.xlsx 中的某些内容存在问题”
- docker - VMware Photon - Clair 无法扫描 vSphere 上的 Photon 容器漏洞
- shell - 将部分 getopts 共享为函数
- apache-spark - Spark-Streaming 最早因 kafka 起始偏移而挂起(Kafka 2,spark 2.4.3)
- python - 在“with”语句中检索代码
- pytorch - Pytorch张量乘法与浮点张量给出错误答案
- git - Git无法在http代理后面的dockerfile中工作