[英]Un-editable form fields for anonymous users
I want to create form fields un-editable for anonymous users, that can be editable for other registered users. 我想创建对匿名用户不可编辑的表单域,对于其他注册用户可编辑。 How can I do?
我能怎么做? I am using the webform module with Drupal 7.
我在Drupal 7中使用webform模块。
Create a custom module and use hook_form_alter to achieve that. 创建一个自定义模块,并使用hook_form_alter来实现。
function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id)
{
if($form_id == "YOUR_FORM_ID")
{
$form['name']['#disabled'] = TRUE; // or something similar.
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.