Posted by minhkhue on January 20, 2012 at 9:10am
Xin chao, minh dang can mot su giup do ve van de sau.
Minh co 2 tab, 1 tab user va 1 tab car. Trong tab user se co 1 column chu' id cua car.
Minh dang tao mot cai form trong do co 2 fields dang select. Fields thu 1 den chon user, va dua theo value dc chon, fields thu 2 se lua chon id car co lien quan den user do.
Minh k biet lam the nao.
Cam on moi nguoi.
Comments
Bạn down module example về
Bạn down module example về rồi xem. Có thể làm bằng ajax rất dễ dàng.
ITFS Software
http://symphonythemes.com
Thank you
Thank you for your comment and link to your site. Unfortunately I do not speak Vietnamese and can only communicate in English and Japanese.
Thank you-
Sorry....
Sorry, I thought that was a private message to me (because I could not read it). Please ignore.
Oh. no problem!
Oh. no problem!
ITFS Software
http://symphonythemes.com
Van de ve values cua form.
Minh da lam theo example ajax. Nhung co van de ma minh thuc su ko giai thich duoc.
Minh co 2 form , va minh da viet ajax nhu sau
$form['ajouter']['admin_group'] = array(
'#type' => 'select',
'#options' => $admin_users,
'#title' => t('Administrateur du groupe'),
'#ajax' => array(
'callback' => 'gt_configuration_add_form_callback',
'wrapper' => 'get_group',
),
);
$form['ajouter']['nom_group'] = array(
'#type' => 'textfield',
'#title' => 'Nom du groupe',
'#prefix' => '', //cho nay minh k biet sao lai ko the show id = get_group , nhung do k phai van de
'#suffix' => '',// phan nay cung the, bao dam dung
'#disabled' => TRUE,
);
va minh viet function ajax nhu sau :
function gt_configuration_add_form_callback($form,$form_state){
//noi dung cua callback la cung cap values cho form 'nom_group'
$admin_group = $form_state['values']['admin_group'];
$user = user_load(array('uid' => $admin_group));
$search_group = db_select('gt_groups','g')
->fields('g',array('nom'))
->condition('id_group',$user->data['groupe'],'=')
->execute()
->fetchAll();
$form['ajouter']['nom_group']['#value'] = $search_group[0]->nom;
return $form ['ajouter']['nom_group'];
}
Ajax chay tot, form 'nom_group' show dung values ma minh muon. Nhung dieu lam minh ko the hieu duoc la. Khi minh submit, values cua form 'nom_group' tro thanh NULL.
Co ai co the giai thich dieu nay giup minh ko?
có sự sai sót trong khai báo form
Bạn đang khai báo là:
$form['ajouter']['nom_group'] = array(
'#type' => 'textfield',
'#title' => 'Nom du groupe',
'#prefix' => '', //cho nay minh k biet sao lai ko the show id = get_group , nhung do k phai van de
'#suffix' => '',// phan nay cung the, bao dam dung
'#disabled' => TRUE,
);
bạn phải remove '#disabled' => TRUE, đi:
$form['ajouter']['nom_group'] = array(
'#type' => 'textfield',
'#title' => 'Nom du groupe',
'#prefix' => '', //cho nay minh k biet sao lai ko the show id = get_group , nhung do k phai van de
'#suffix' => '',// phan nay cung the, bao dam dung
);
thì sẽ ok thôi.