I have a Drupal form, with a tableselect element:
$form['items'] = array(
'#type' => 'tableselect',
'#prefix' => '<div id="wrapper-i">',
'#suffix' => '</div>',
'#header' => $header,
'#options' => _ajax_items_options($selected),
'#multiple' => TRUE,
'#empty' => t('No hay elementos para ingresar'),
);
I need all items are checked initially. This Items change through ajax in function of a previous select element form:
$form['entidad'] = array(
'#type' => 'select',
'#title' => t('Selecciona'),
'#options' => $entidades,
'#description' => t('Formas disponibles'),
'#ajax' => array(
// 'event' => 'change',
'callback' => 'ajax_items_callback',
'wrapper' => 'wrapper-i',
'effect' => 'slide',
),
);
How I can check all items at tableselect element?
At tableselect element I added:
'#default_value' => _ajax_items_options_check($selected)
_ajax_items_options_checks returns a array like this
$check[1]=true
$check[2]=true
The first time all items are checked, but when I change select element, with ajax, the tableselect form element will change your data but not refresh #default_value and items are not checked.
What am I doing wrong?