giup do ve cach tao mot fields dang select tu mot fields dang select khac

Events happening in the community are now at Drupal community events on www.drupal.org.
minhkhue's picture

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ề

khuongkd's picture

Bạn down module example về rồi xem. Có thể làm bằng ajax rất dễ dàng.

Thank you

dndood's picture

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....

dndood's picture

Sorry, I thought that was a private message to me (because I could not read it). Please ignore.

Oh. no problem!

khuongkd's picture

Oh. no problem!

Van de ve values cua form.

minhkhue's picture

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

antesla's picture

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.