欢迎各位兄弟 发布技术文章
这里的技术是共享的
function custom_one_form_alter(&$form, &$form_state, $form_id)
{
if ('cjdntj_node_form' == $form_id) {
// global $user;
// if($user->uid==1){
// $e = kprint_r($form,TRUE);
// print $e;
// $e = kprint_r($form_state,TRUE);
// print $e;
// if(!empty($form['field_user']['und']['#default_value'])){
// }
// }
if (!empty($form_state['build_info']['args'][0]->field_user['und'][0]['target_id'])) {
$field_user_id = $form_state['build_info']['args'][0]->field_user['und'][0]['target_id'];
$user_from_db = user_load($field_user_id);
$form['field_user']['und']['#default_value'] = $user_from_db->field_full_name['und'][0]['value'] . ' - ' . $user_from_db->name . ' (' . $field_user_id . ')';
}
_remove_no_needed_field_work_address($form);
$form['#validate'][] = 'custom_one_cjdntj_node_form_validate';
$form['actions']['submit']['#submit'][] = 'custom_one_cjdntj_node_submit_do_redirect';
// $form['#redirect'] = array('list_cjdntj');
}
if ('to_do_node_form' == $form_id) {
// $e = kprint_r($form,TRUE);
// print $e;
// $e = kprint_r($form_state,TRUE);
// print $e;
foreach ($form['field_accepter']['und'] as $key => $value) {
if (is_numeric($key)) {
if (!empty($form['field_accepter']['und'][$key]['target_id']['#default_value'])) {
$field_accepter_uid = $form_state['build_info']['args'][0]->field_accepter['und'][$key]['target_id'];
$user_from_db = user_load($field_accepter_uid);
$field_accepter_val = $user_from_db->field_full_name['und'][0]['value'] . ' (' . $field_accepter_uid . ')';
$form['field_accepter']['und'][$key]['target_id']['#default_value'] = $field_accepter_val;
}
}
}
}
if ('yunweigongzuorichang_node_form' == $form_id) {
// $e = kprint_r($form,TRUE);
// print $e;
// $e = kprint_r($form_state,TRUE);
// print $e;
if (!empty($form['field_user']['und']['#default_value'])) {
$field_user_id = $form_state['build_info']['args'][0]->field_user['und'][0]['target_id'];
$user_from_db = user_load($field_user_id);
$field = field_info_field('field_diqu');
$allowed_values = list_allowed_values($field);
$diqu = $allowed_values[$user_from_db->field_diqu['und'][0]['value']];
$full_name = $user_from_db->field_full_name['und'][0]['value'];
$field_user_val = $diqu.' - ' . $full_name .'- '.$user_from_db->name.' ('.$user_from_db->uid.')';
$form['field_user']['und']['#default_value'] = $field_user_val;
}
$form['#validate'][] = 'custom_one_yunweigongzuorichang_node_form_validate';
}
}
function custom_twenty_two_jses_form_alter(&$form, &$form_state, $form_id)
{
if ('jses_terminal_manager_node_form' == $form_id) {
$field_user_id = $form['field_user']['und']['#entity']->field_user['und'][0]['target_id'];
if (!empty($field_user_id)) {
$user_from_db = user_load($field_user_id);
$form['field_user']['und']['#default_value'] = _my_get_diqu_tag_by_value($user_from_db->field_diqu['und'][0]['value']) . ' - ' . $user_from_db->field_full_name['und'][0]['value'] . ' - ' . $user_from_db->name . ' (' . $field_user_id . ')';
}
$form['#validate'][] = 'custom_twenty_two_jses_terminal_manager_node_form_validate';
$form['#after_build'][] = 'custom_twenty_two_jses_form_afterFormSelect';
// $e = kprint_r($form,TRUE);
// print $e;
// $e = kprint_r($form_state,TRUE);
// print $e;
}
if ('jses_dhcp_node_form' == $form_id) {
$field_user_id = $form['field_user']['und']['#entity']->field_user['und'][0]['target_id'];
if (!empty($field_user_id)) {
$user_from_db = user_load($field_user_id);
$form['field_user']['und']['#default_value'] = $user_from_db->field_full_name['und'][0]['value'] . ' - ' . $user_from_db->name . ' (' . $field_user_id . ')';
}
}
}
function custom_seventeen_send_mail_form_alter(&$form, &$form_state, $form_id)
{
if('send_mail_node_form' == $form_id){
$field_user_id = $form['field_recipient']['und']['#entity']->field_recipient['und'][0]['target_id'];
if (!empty($field_user_id)) {
$user_from_db = user_load($field_user_id);
$form['field_recipient']['und']['#default_value'] = _my_get_diqu_tag_by_value($user_from_db->field_diqu['und'][0]['value']).' - '.$user_from_db->field_full_name['und'][0]['value'] . ' - ' . $user_from_db->name . ' - ' .$user_from_db->mail. ' (' . $field_user_id . ')';
}
//$e = kprint_r($form['actions'],TRUE);
//print $e;
$form['actions']['submit']['#value'] = "发送 & 保存";
$form['#validate'][] = 'custom_seventeen_send_mail_form_validate';
// $form['#submit'][] = 'custom_seventeen_send_mail_form_submit'; //这个就是覆盖以前的 submit
$form['actions']['submit']['#submit'][] = 'custom_seventeen_send_mail_form_submit'; //这个就是覆盖以前的 submit
}
}