所以我有三种类型的用户 - 管理员,LA管理员和用户.我正在尝试设置它,以便管理员和LA管理员无法编辑用户的用户名,密码和时区.我说的是管理员的默认用户编辑表单,表单ID是"user-profile-form".
我已经创建了一个自定义模块,但这似乎不起作用.知道我可能做错了什么吗?
甚至var_dump似乎也没有输出.我已清除缓存并验证模块已启用.
function profile_change_form_alter(&$form, $form_state, $form_id) {
if ($form_id === 'user-profile-form') {
var_dump ($form);
hide($form['account']['pass']);
hide($form['account']['current_pass_required_values']);
hide($form['account']['current_pass']);
}
}
Run Code Online (Sandbox Code Playgroud) 我需要在用户创建后在我的表中插入数据.我想用hook_form_alter()
,$form_id == "user_register"
但我不知道怎么说"在你创建用户之后,做这个."
我怎么能这样做hook_form_alter()
?
我已经使用form_alter函数来更改组件的值,但它没有更改,默认值存储在db中.当我打印$ form时,更新的值显示但未保存在db中.
<?php
function pahcom_form_edit_module_form_alter(&$form, &$form_state, $form_id) {
if($form_id =='webform_client_form_54')
{
$new_value = rand(100000,10000000);
$form['#node']->{'webform'}['components']['12']['value']=$new_value;
}
}
?>
Run Code Online (Sandbox Code Playgroud) 我正在尝试更改节点添加表单上的图像小部件中的"alt"和标题"标签".
我试过这两个钩子:
hook_field_widget_form_alter
hook_form_alter
Run Code Online (Sandbox Code Playgroud)
我无法找到我需要去哪里成功改变标签.有人可以指导我以适当的方式加入这个并改变它们吗?如果它有所作为,我正在从自定义模块中击中它们.通过主题击中它们对我来说也没问题.
任何人的想法?
我有一个我正在创建的模块,其目的是导入特定类型的数据,并根据该数据将其附加到节点.
为此,我需要创建一个页面,让用户输入存储数据的位置,以便系统导入.
为此,我正在挂钩hook_menu来创建这样的页面:
function lbar_image_importer_menu(){
$items = array();
$items[] = array(
'path' => "admin/content/lbar_image_importer",
'title' => "Import LBar Images",
'description' => "Innitiate an importation of LBar images from a ZIP file.",
'page callback' => 'drupal_get_form',
);
return $items;
}
Run Code Online (Sandbox Code Playgroud)
我通过挂钩到hook_form_alter函数来填充它将使用的表单,如下所示:
function lbar_image_importer_form_alter(&$form, &$form_state, $form_id) {
$form['admin']['lbar_zip_loc'] = array(
'#type' => 'textfield',
'#title' => 'Location of LBar Zip file: ',
'#description' => 'This is where one or many of the lbar zip files are located. If this is a file, it …
Run Code Online (Sandbox Code Playgroud)