Drupal ajax callback changes a table select but not #options

i’m using an ajax callback for a submit button. i want to change values of a tableselect after making choice on a list and submitting. before adding ajax, when i make a dsm ($form) or dsm ($form[mytableselect’][‘#option’] it shows me my array with the good things (the db_select works well) . but when i add ajax callback (with wrapper prefix/suffix on my table select) everythig change on my table select (#header, #empty) but not #options!
dit the submit callback function (for ajax)can support a db query + showing result ?

this is my callback code :

function livre_formulaire_submit($form, &$form_state){

$cond = $form_state['values']['etat_livre'];
$header  = array(
    'book_title' => t('title'),
    'book_etat' => t('etat'),
    'book_categories' => t('categorie'),
    'book_editeur' => t('editor'),
    'book_prix' => t('price'),
);

$sql = db_select('field_data_field_title','ta');
$sql->join('field_data_field_price','pr','pr.entity_id = ta.entity_id');
$sql->join('field_data_field_editor','ed','ed.entity_id = pr.entity_id');
$sql->join('field_data_field_categorie','cat','cat.entity_id = ta.entity_id');
$sql->join('taxonomy_term_data','tax','tax.tid = cat.field_categorie_tid');
   $sql->join('field_data_field_etat','et','et.entity_id = pr.entity_id');

$sql
    ->fields('ta', array('field_title_value','entity_id'))
    ->fields('pr', array('field_price_value','entity_id'))
    ->fields('ed',array('field_editor_value','entity_id'))
    ->fields('cat', array('field_categorie_tid','entity_id'))
    ->fields('tax', array('tid','name'))        
    ->fields('et',array('field_etat_value'));       

   $sql->condition('et.field_etat_value',$cond);
   $req = $sql->execute();


$rows = array();

foreach ($req as $q){ 

     $rows [] = array(
        'book_title' => $q ->field_title_value,
        'book_etat' => $q ->field_etat_value,
        'book_editor' => $q ->field_editor_value,
        'book_categories' => $q ->name,
        'book_price' => $q ->field_price_value
      );

   }

   $form['table'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $rows,
    '#empty' => t('EMPTY'),
     );

     $return $form['table'];
    }

my question is : is the callback ajax can be like mine ?


Source: ajax

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.