Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Drupal6中使选择框字段(CCK)只读?_Drupal_Drupal 6_Cck - Fatal编程技术网

如何在Drupal6中使选择框字段(CCK)只读?

如何在Drupal6中使选择框字段(CCK)只读?,drupal,drupal-6,cck,Drupal,Drupal 6,Cck,我想使选择框(CCK)字段为只读,而不是禁用,以便我可以在提交中获取该字段。我使用以下代码对文本字段进行了尝试: $form['field_example'][0]['value']['#attributes']['readonly'] = 'readonly'; 但对于选择框,我不能。几乎我只能禁用它。那么有没有办法让它成为只读的呢 提前谢谢。不,那不行! 您需要使用正确的formid编写hook_form_alter,使字段“#disabled”=>为TRUE,嗨,joshi,谢谢您宝贵的

我想使选择框(CCK)字段为只读,而不是禁用,以便我可以在提交中获取该字段。我使用以下代码对文本字段进行了尝试:

$form['field_example'][0]['value']['#attributes']['readonly'] = 'readonly';
但对于选择框,我不能。几乎我只能禁用它。那么有没有办法让它成为只读的呢

提前谢谢。

不,那不行!
您需要使用正确的formid编写hook_form_alter,使字段“#disabled”=>为TRUE,

嗨,joshi,谢谢您宝贵的回答。是的,我已经通过hook_form_alter['#attributes'['disabled']='disabled'完成了这项工作;但是,一旦我禁用了select字段值,我是否可以在form_state['values']中获取它呢。?提前谢谢。请更正它--它不是“#disabled”=>“disabled”,而是“#disbled”=>真的,您还忘记了属性中的“#”。此外,它将不在“属性”下,而是一个单独的属性。请查看Drupal.org上的表单api