Ciao a tutti,
c'è un problema che mi assilla da diversi giorni e non ne vengo a capo...
In un modulo personale ho creato un form:
<?php
[...]
$form['projectClient'] = array(
'#title' => 'Project',
'#type' => 'fieldset',
);
$form['projectClient']['userList'] = array(
'#type' => 'select',
'#title' => 'Client',
'#required' => TRUE,
'#options' => $clients,
'#default_value' => isset($form['#node']->custom_field['client']) ? $form['#node']->custom_field['client'] : '',
'#ajax' => array(
'callback' => 'ajax_select_project',
'wrapper' => 'project-div',
'method' => 'replace',
'effect' => 'fade',
'progress' => array(
'message' => NULL,
'type' => 'throbber',
),
),
'#empty_option' => t('- Select -'),
);
$form['projectClient']['project'] = array(
'#title' => 'Project',
'#type' => 'select',
'#options' => array(10 => 'Prova 1', 20 => 'Prova 2'),
'#default_value' => isset($form['#node']->custom_field['project']) ? $form['#node']->custom_field['project'] : '',
'#prefix' => '<div id="project-div">',
'#suffix' => '</div>',
'#empty_option' => t('- Select -'),
);
?>
E fin qui tutto bene...
Poi ajax richiama questa funzione
<?php
function ajax_select_project($form, $form_state) {
$resultTask = db_query("SELECT n.nid, n.title FROM {node} n LEFT JOIN {pms_project} p ON n.nid = p.nid WHERE n.type = 'pms_project' AND p.client = :client", array(':client' => $form['projectClient']['userList']['#value']));
foreach($resultTask as $task) {
$allTask[$task->nid] = $task->title;
}
$form['projectClient']['project']['#options'] = $allTask;
return $form['projectClient']['project'];
}
?>
E anche qui tutto bene ma quando faccio il submit mi da Illegal chois e non capisco perchè...