php - Drupal submitting a query that change a tableselect -


i'm new on drupal, i've create module shows form select, button submit , i've got tableselect lists records (from database). tableselect works , it's listing records, want "filter" records on tableselect selecting want see select list (and submitting). when choose in select list , submit, tableselect dont change if execute dsm($form['tableselect']) said tableselect contains db_query returns.

here form :

 function mybook_form ($form, &$form_state){    $form = array();   $form['options_state'] = array(   '#type' => 'value',   '#value' => array (     'all'=>t('all'),     'valid'=>t('valid'),     'published'=>t('published'),     'not published'=>t('not published')      )    );    $form['state_book'] = array( '#type' => 'select', '#title' => t('state :'),                      '#options' => $form['options_state']['#value'],          );     // filter submit button   $form['filter'] = array( '#type' => 'submit', '#value' => t('filter')                 ); }   $header  = array( 'book_title' => t('title'), 'book_state' => t('state'),      );  $sql = db_select('field_data_field_title','ta'); $sql->join('field_data_field_state','st','st.entity_id = ta.entity_id');   $sql     ->fields('ta',   array('field_title_value','entity_id'))            ->fields('st',array('field_state_value'));     $result = $sql->execute();   $rows = array();    foreach ($result $res){     $rows [] = array(     'book_title' => l($res->field_title_value,  'node/'.$res->entity_id),     'book_state' => $res->field_state_value              );     }   $form['table1'] = array( '#type' => 'tableselect', '#header' => $header, '#options' => $rows, '#empty' => t('empty !'),    );    return $form; 

here submit function :

function book_form_submit($form, &$form_state){     $cond = $form_state['values']['state_book'];   $header  = array( 'book_title' => t('title'), 'book_state' => t('state'),  );     $sql = db_select('field_data_field_title','ta');    $sql->join('field_data_field_state','st','st.entity_id = ta.entity_id');    $sql     ->fields('ta', array('field_title_value'))             ->fields('st',array('field_state_value'));     $sql->condition('st.field_state_value', $cond, '=');            $quer = $sql->execute();   $rows = array();   foreach ($quer $q){       array_push($rows, array(     'book_title' => $q->field_title_value,     'book_state' => $q->field_state_value,        ));        }         $form['table2'] = array(    '#type' => 'tableselect',    '#header' => $header,    '#options' => $rows,    '#empty' => t('empty!')   );       } 

thanks


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -