[support] strange value  from form or bug ?
    Metzler, David 
    metzlerd at evergreen.edu
       
    Mon Feb 25 16:04:28 UTC 2008
    
    
  
Probably because the numeric cast of a string is 0. 
Try this: 
if (!$form_values['dati']['ecomm'] ) $ecomm2 = 0;
     else $ecomm2 = 1;
or this: 
if ($form_values['dati']['ecomm'] === 0) $ecomm2 = 0;
     else $ecomm2 = 1;
-----Original Message-----
From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of Davide Michel 'ZioBudda' Morelli
Sent: Sunday, February 24, 2008 4:19 PM
To: support at drupal.org
Subject: [support] strange value from form or bug ?
Hi all. I have created a form with this select:
$form['dati'] = array (
        '#title' => 'Dati',
        '#type' => 'checkboxes',
        '#description' => 'Settagi per il livello',
        '#options' => array('ecomm' => 'Visibile Ecomm','visibile' => 
'Visibile altri form','default' => 'Default')
        );
I have this _submit fom():
function add_lU_form_submit($form,$form_values) {
    if ($form_values['dati']['ecomm'] == 0) $ecomm2 = 0;
    else $ecomm2 = 1;
   
    if ($form_values['dati']['visibile'] == 0) $visibile = 0;
    else $visibile = 1;
    var_dump($ecomm2);
    var_dump($visibile);
    exit; //Test stop here;
  [....]
}
So, In the output form I check the Ecomm field so $form_values['dati']
is :
array(3) {
  ["ecomm"]=>
  string(5) "ecomm"
  ["visibile"]=>
  int(0)
  ["default"]=>
  int(0)
}
Now: why this piece of function (say above) give always 0 :
 if ($form_values['dati']['ecomm'] == 0) $ecomm2 = 0;
     else $ecomm2 = 1;
I don't' understand why.
Tnx.
-- 
Michel 'ZioBudda' Morelli                       michel at ziobudda.net
Consulenza sistemistica in ambito OpenSource.
Sviluppo applicazioni web dinamiche (LAMP+Ajax)
Telefono: 0200619074
Telefono Cell: +39-3939890025 --  Fax: +39-0291390660
http://www.ziobudda.net                         ICQ: 58351764  
http://www.ziobuddalabs.it                      Skype: zio_budda
http://www.ajaxblog.it        			MSN:
michel at ziobuddalabs.it                   
						JABBER: michel at gmail.com
-- 
[ Drupal support list | http://lists.drupal.org/ ]
    
    
More information about the support
mailing list