欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

drupal 表单 设置 表单字段 属性 修改class 修改 其它属性等 有大用 有大大用 有大大大用 有大大大大用

function shipingzhongcustomnine_form_alter(&$form, &$form_state, $form_id)
{
   
global $user;
   
if($form_id == 'kefuchat_node_form'){

       
//设置去掉时间 表单字段自动完成
       
$form['#after_build'][] = 'shipingzhongcustomnine_setTimeAutoCompleteOff';

       
//如果 是且仅是整骨 角色
       // if((in_array('是且仅是整骨',$user->roles))){
       
if(_kefuchat_node_form_xuexiao_or_zhenggu()=='kefuchat_node_form_zg'){
           
$form['#after_build'][] = 'shipingzhongcustomnine_afterFormSelect';
       }

   }
}



function shipingzhongcustomnine_setTimeAutoCompleteOff($form, &$form_state){
   
_setTimeAutoCompleteOff($form['field_shangmeng_time']);
   
_setTimeAutoCompleteOff($form['field_genzong_time']);
   
_setTimeAutoCompleteOff($form['field_baoming_time']);
   
_setTimeAutoCompleteOff($form['field_genzong_next_time']);
   
return $form;
}



function _setTimeAutoCompleteOff(&$elements){
   
foreach (element_children($elements) as $key) {
       
if (isset($elements[$key]) && $elements[$key]) {
           
// Recurse through all children elements.
           
_setTimeAutoCompleteOff($elements[$key]);
       }
   }
   
if (!isset($elements['#attributes'])) {
       
$elements['#attributes'] = array();
   }
   
$elements['#attributes']['autocomplete'] = 'off';
   $elements['#attributes']['class'] = 'aaaaa';

}


普通分类: