In a form I have both select and checkboxes fields. Select can have one choice only, checkboxes can have multiple choices.

When I call the submit function (see at the end) I get the right value for each select but I do not get any value (there should be more then one) for the checkboxes. I get the message : "Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1584 of C:\00000 Drupal\includes\bootstrap.inc). muchcethe values"

Anyone knows how to fix it ?

Thanks

Angelo

Submit function (regioneprovenienza, provinciaproveninenza and regionedestinazione are select, while provinciadestinazione is a checkboxes):

// ......
function mobilita_inserimento_dropdown_submit($form, &$form_state) {

  switch ($form_state['triggering_element']['#value']) {
    case t('OK'):
 drupal_set_message(t('Your choice is: regioneprovenienza=@first, provinciaprovenienza=@second, regionedestinazione=@third, provinciadestinazione=@fourth', array('@first' =>     $form_state['values']['dropdown_first'], '@second' => $form_state['values']['dropdown_second'], '@third' => $form_state['values']['dropdown_third'], '@fourth' => $form_state['values']['dropdown_fourth'])));
	
	      return;
  }
// .....

Comments

nevets’s picture

It returns an array of values when you can select more than one value.

AngCar’s picture

I got it from the error message, but how to pass the array of values to drupal set messate ?
Thanks

nevets’s picture

I use something like

drupal_set_message('Values:<pre>' . print_r($array_of_values, TRUE) . '</pre>');
AngCar’s picture

Thanks: it works!