欢迎各位兄弟 发布技术文章
这里的技术是共享的
if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
$form['#after_build'][] = 'my_form_process';
}
}
function my_form_process($form, &$form_state) {
my_fix_disabled($form['field_myfiled']);
return $form;
}
function my_fix_disabled(&$elements) {
foreach (element_children($elements) as $key) {
if (isset($elements[$key]) && $elements[$key]) {
// Recurse through all children elements.
my_fix_disabled($elements[$key]);
}
}
if (!isset($elements['#attributes'])) {
$elements['#attributes'] = array();
}
$elements['#attributes']['disabled'] = 'disabled';
$elements['#attributes']['class'] = 'aaaaa';
}
来自 https://www.drupal.org/node/336355