How can I hide the product using ajax callback . I am trying to implement that using ajax_commands_invoke but it does not work using below code
$form['field_product_type_select']['und']['#ajax']= array('callback' => '_change_table_product_type','wrapper' => 'display-table-ajaxify'); $header = array( 'field_name' => t('Field Name'), 'field_type' => t('Field Type'), 'field_no_of_values' => t('Single/Multi Value'), ); $options = array(); foreach(commerce_product_types() as $product_type => $product_type_array){ $field_info_instances = field_info_instances('commerce_product',$product_type); foreach($field_info_instances as $key => $value){ $field_info_types = field_info_field_types($value['type']); $options[$key] = array( 'field_name' => $value['label'], 'field_type' => $field_info_types['label'], 'field_no_of_values' => $value['cardinality'], ); } $form['display_table'][$product_type] = array( '#type' => 'tableselect', '#options' => $options, '#header' => $header, '#multiple' => TRUE, '#prefix' => '<div class="display-'.$product_type.'" id="display-table-ajaxify" style="display:none;"><b>'. $product_type_array['name'].'</b>', '#suffix' => '</div>', ); } function _change_table_product_type(&$form,&$form_state){ $commands = array(); $product_type = $form_state['values']['field_product_type_select']['und'][0]['value']; drupal_set_message($product_type); $commands[] = ajax_command_invoke('display-'.$product_type,'show'); /* $product_type = $form_state['values']['field_product_type_select']['und'][0]['value']; */ /* foreach ($form['display_table'] as $key => $value){ */ /* if ($key != $product_type) { */ /* unset($form['display_table'][$key]); */ /* } */ /* } */ // return $form['display_table'][$product_type]; // return array('#type' => 'ajax', '#commands' => $commands); print ajax_render($commands); }