Hello.

i'm baking a small concept-app, just for training.

atm i have 2 models with their own relationship.

Oder hasMany Item

my "order/add" view contains a form like this:

<?php echo $form->create('Order');?>
        <fieldset>
                <legend>Order data</legend>
                <?php
                        //Order.Code is automatically generated by the app.
                        echo $form->input('Order.Code', array('readonly' => 
'readonly'));
                ?>
        </fieldset>
        <fieldset>
                <legend>Order's items</legend>
                <table class="form_orizzontale">
                        <thead>
                                <tr>
                                        <td>Line</td>
                                        <td>Item</td>
                                        <td>Quantity</td>
                                </tr>
                        </thead>
                        <tbody>
                                <?php for($i = 1; $i <= 10; $i++) { ?>
                                <tr>
                                        <td><?php echo $i ?></td>
                                        <td><?php echo 
$form->input('Item.$i.item_id'); ?></td>
                                        <td><?php echo 
$form->input('item.$i.quantity); ?></td>
                                </tr>
                        <?php
                        }
                        ?>
                        </tbody>
                </table>
        </fieldset>
<?php echo $form->end('Submit');?>

this form generates a data array like this

Array
(
    [Oder] => Array
        (
            [Code] => AAABBBCCC
        )

    [Item] => Array
        (
            [1] => Array
                (
                    [item_id] => 3
                    [quantity] => 2
                )

            [2] => Array
                (
                    [item_id] => 2
                    [quantity] => 5
                )

        )

)

And here's my OrderController's add function

function add() {
        if (empty($this->data)) {

                //the order code should be generated using current time
                $this->data["Order"]["Code"] = "AAABBBCCC";

        } else {

                if ($this->Order->saveAll($this->data)) {

                                    $this->flash("Success.", "/
order");

                        } else {

                                    $this->set("errors", $this->Order-
>validationErrors);

                        }
            }
}

When i press the "submit" button i get a "Success" message... but no
data is added... my CakePHP's debug output is something like this

10      [Count Query]
11      START TRANSACTION
12      START TRANSACTION
13      [Count Query]
14      ROLLBACK
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to