quickform exported group values differ from $_POST but shouldn't

From: Date: Fri, 30 Jan 2004 14:43:30 +0000
Subject: quickform exported group values differ from $_POST but shouldn't
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-25342@lists.php.net to get a copy of this message
Hi, using: QF 3.2.1 PHP 4.3.4 Smarty Array renderer CVS I have a somewhat complex form that includes this: $types = array ( "existsthisyear", "addthisyear", "addin2years" ); foreach ($types as $type) { $connections = $db->getAll("SELECT network, capacity FROM ext_connections WHERE nrenID=$nrenID AND status=".$db->quote($type)); $i=0; foreach ($connections as $conn) {
       $group[] = &HTML_QuickForm::createElement('text',  "name", null, array("size"=>30,"maxlength"=>75));
       $group[] = &HTML_QuickForm::createElement('text',  "capacity", null, array("size"=>30,"maxlength"=>75));
       $form->addGroup($group, "networks[$type][$i]");
       $defaults["networks"][$type][$i] = array("name" => $conn['network'], "capacity" => $conn['capacity']);
       unset($group);
       $i++;
} } This output (in HTML) the following (which is what I wanted): <table> <tr> <th colspan="2">Operational external connections in January 2004</th> </tr> <tr> <th>Network</th> <th>Usable capacity in Mbit/s</th> </tr> <tr> <td><input size="30" maxlength="75" name="networks[existsthisyear][0][name]" type="text" value="GEANT" /> </td> <td><input size="30" maxlength="75" name="networks[existsthisyear][0][capacity]" type="text" value="2488" /> </td> </tr> <tr> <td><input size="30" maxlength="75" name="networks[existsthisyear][1][name]" type="text" value="Global Crossing" /> </td> <td><input size="30" maxlength="75" name="networks[existsthisyear][1][capacity]" type="text" value="2488" /> </td> </tr> <tr> <td><input size="30" maxlength="75" name="networks[existsthisyear][2][name]" type="text" value="MIX - Milan Internet Exchange" /> </td> <td><input size="30" maxlength="75" name="networks[existsthisyear][2][capacity]" type="text" value="155" /> </td> </tr> <tr> <td><input size="30" maxlength="75" name="networks[existsthisyear][3][name]" type="text" value="NAMEX - Rome Internet Exchange" /> </td> <td><input size="30" maxlength="75" name="networks[existsthisyear][3][capacity]" type="text" value="200" /> </td> </tr> <tr> <td><input size="30" maxlength="75" name="networks[existsthisyear][4][name]" type="text" value="TELIA" /> </td> <td><input size="30" maxlength="75" name="networks[existsthisyear][4][capacity]" type="text" value="2488" /> </td> </tr> </table> <table> <tr> <th colspan="2">Expected additions or upgrades during 2004</th> </tr> <tr> <th>Network</th> <th>Usable capacity in Mbit/s</th> </tr> <tr> <td><input size="30" maxlength="75" name="networks[addthisyear][0][name]" type="text" value="GEANT" /> </td> <td><input size="30" maxlength="75" name="networks[addthisyear][0][capacity]" type="text" value="10000" /> </td> </tr> <tr> <td><input size="30" maxlength="75" name="networks[addthisyear][1][name]" type="text" value="MIX" /> </td> <td><input size="30" maxlength="75" name="networks[addthisyear][1][capacity]" type="text" value="1000" /> </td> </tr> <tr> <td><input size="30" maxlength="75" name="networks[addthisyear][2][name]" type="text" value="NAMEX" /> </td> <td><input size="30" maxlength="75" name="networks[addthisyear][2][capacity]" type="text" value="1000" /> </td> </tr> </table> <table> <tr> <th colspan="2">Expected connections in January 2006</th> </tr> <tr> <th>Network</th> <th>Usable capacity in Mbit/s</th> </tr> <tr> <td><input size="30" maxlength="75" name="networks[addin2years][0][name]" type="text" value="GEANT" /> </td> <td><input size="30" maxlength="75" name="networks[addin2years][0][capacity]" type="text" value="10000" /> </td> </tr> <tr> <td><input size="30" maxlength="75" name="networks[addin2years][1][name]" type="text" value="Global Crossing" /> </td> <td><input size="30" maxlength="75" name="networks[addin2years][1][capacity]" type="text" value="10000" /> </td> </tr> <tr> <td><input size="30" maxlength="75" name="networks[addin2years][2][name]" type="text" value="MIX - Milan Internet Exchange" /> </td> <td><input size="30" maxlength="75" name="networks[addin2years][2][capacity]" type="text" value="10000" /> </td> </tr> <tr> <td><input size="30" maxlength="75" name="networks[addin2years][3][name]" type="text" value="NAMEX - Rome Internet Exchange" /> </td> <td><input size="30" maxlength="75" name="networks[addin2years][3][capacity]" type="text" value="10000" /> </td> </tr> <tr> <td><input size="30" maxlength="75" name="networks[addin2years][4][name]" type="text" value="TELIA" /> </td> <td><input size="30" maxlength="75" name="networks[addin2years][4][capacity]" type="text" value="10000" /> </td> </tr> </table> After submitting the form I do a print_r of the exported networks array values and $_POST['networks'], like so: $qf = $form->exportValues(); print_r($_POST['networks']); print_r($qf['networks']); Why is the output different? $_POST['networks'] gives me: Array ( [existsthisyear] => Array
       (
           [0] => Array
               (
                   [name] => GEANT
                   [capacity] => 2488
               )
           [1] => Array
               (
                   [name] => Global Crossing
                   [capacity] => 2488
               )
           [2] => Array
               (
                   [name] => MIX - Milan Internet Exchange
                   [capacity] => 155
               )
           [3] => Array
               (
                   [name] => NAMEX - Rome Internet Exchange
                   [capacity] => 200
               )
           [4] => Array
               (
                   [name] => TELIA
                   [capacity] => 2488
               )
       )
[addthisyear] => Array
       (
           [0] => Array
               (
                   [name] => GEANT
                   [capacity] => 10000
               )
           [1] => Array
               (
                   [name] => MIX
                   [capacity] => 1000
               )
           [2] => Array
               (
                   [name] => NAMEX
                   [capacity] => 1000
               )
       )
[addin2years] => Array
       (
           [0] => Array
               (
                   [name] => GEANT
                   [capacity] => 10000
               )
           [1] => Array
               (
                   [name] => Global Crossing
                   [capacity] => 10000
               )
           [2] => Array
               (
                   [name] => MIX - Milan Internet Exchange
                   [capacity] => 10000
               )
           [3] => Array
               (
                   [name] => NAMEX - Rome Internet Exchange
                   [capacity] => 10000
               )
           [4] => Array
               (
                   [name] => TELIA
                   [capacity] => 10000
               )
Which is exactly what I want. $qf['networks'] gives me: Array ( [existsthisyear] => Array
       (
           [0] => Array
               (
                   [name] => GEANT
               )
           [1] => Array
               (
                   [capacity] => 2488
               )
           [2] => Array
               (
                   [name] => Global Crossing
               )
           [3] => Array
               (
                   [capacity] => 2488
               )
           [4] => Array
               (
                   [name] => MIX - Milan Internet Exchange
               )
           [5] => Array
               (
                   [capacity] => 155
               )
           [6] => Array
               (
                   [name] => NAMEX - Rome Internet Exchange
               )
           [7] => Array
               (
                   [capacity] => 200
               )
           [8] => Array
               (
                   [name] => TELIA
               )
           [9] => Array
               (
                   [capacity] => 2488
               )
       )
[addthisyear] => Array
       (
           [0] => Array
               (
                   [name] => GEANT
               )
           [1] => Array
               (
                   [capacity] => 10000
               )
           [2] => Array
               (
                   [name] => MIX
               )
           [3] => Array
               (
                   [capacity] => 1000
               )
           [4] => Array
               (
                   [name] => NAMEX
               )
           [5] => Array
               (
                   [capacity] => 1000
               )
       )
[addin2years] => Array
       (
           [0] => Array
               (
                   [name] => GEANT
               )
           [1] => Array
               (
                   [capacity] => 10000
               )
           [2] => Array
               (
                   [name] => Global Crossing
               )
           [3] => Array
               (
                   [capacity] => 10000
               )
           [4] => Array
               (
                   [name] => MIX - Milan Internet Exchange
               )
           [5] => Array
               (
                   [capacity] => 10000
               )
           [6] => Array
               (
                   [name] => NAMEX - Rome Internet Exchange
               )
           [7] => Array
               (
                   [capacity] => 10000
               )
           [8] => Array
               (
                   [name] => TELIA
               )
           [9] => Array
               (
                   [capacity] => 10000
               )
       )
Which is *not* what I want. Any clues? Jeroen )
       )


« previous php.pear.dev (#25342) next »