Im attempting to save an archive to some table aswell being an accociated record. The primary table is known as quotes and contains a hasmany connect to the table quote_products. quote_products belongsto quote

After i try to save it saves the record in quote but doesn't save the record in quote_products .

Below is my quote add function

    function add() {
    if (!empty($this->data)) {
        $this->Quote->create();
        if ($this->Quote->saveAll($this->data)) {
            $this->Session->setFlash(__('The Quote has been saved', true));
            //$this->redirect(array('action'=>'index'));
        } else {
            $this->Session->setFlash(__('The Quote could not be saved. Please, try again.', true));
        }
    }
    $this->Quote->recursive = 2;
    $statuses = $this->Quote->Status->find('list');
    $contacts = $this->Quote->Contact->find('list');
    $this->set(compact('statuses', 'contacts'));
}

Quote view / form setup

    <?php echo $form->create('Quote', array('action' => 'add'));?>
    <fieldset>
        <legend><?php __('Add Quote');?></legend>
    <?php
        echo $form->input('Quote.name');
        echo $form->input('Quote.revision');
        echo $form->input('Quote.status_id');
        echo $form->input('Quote.contact_id');
        echo $form->input('quote_item.product_id');
        echo $form->input('quote_item.name');
        echo $form->input('quote_item.price');
        echo $form->input('quote_item.description');
        echo $form->input('Quote.totalcost');
    ?>
    </fieldset>
<?php echo $form->end('Submit');?>

Array that's came back once the form is posted

    Array ( 
    [quote] => Array ( 
                [name] => Test 
                [revision] => 1 
                [status_id] => 1 
                [contact_id] => 1 
                [totalcost] => 123 
              ) 

    [quote_item] => Array ( 
                [product_id] => 1
                [name] => test 
                [price] => 123 
                [description] => tes 1234 
              ) 
) 

This appears to follow along with what is indexed by the cakephp documentation and so i cant exercise why it is not working - http://book.cakephp.org/view/84/Saving-Related-Model-Data-hasOne-hasMany-belongsTo

Thanks ahead of time

The right way to construct the shape could be:

echo $form->input('Quote.name');
...
echo $form->input('QuoteItem.0.product_id');
echo $form->input('QuoteItem.0.name');
...
echo $form->input('QuoteItem.1.product_id');
echo $form->input('QuoteItem.1.name');

The resulting array need to look such as this:

array(
    'Quote' => array(
        'name' => 'Test'
        ....
    ),
    'QuoteItem' => array(
        0 => array(
            'product_id' => 1
            'name' => 'test'
            ...
        )
        1 => array(
            'product_id' => 2
            'name' => 'test'
            ...
        )
    )
)

Based on naming conventions, model names are camelized (ModelName, not model_title). Also, since Quote hasMany QuoteItems, the QuoteItem array must contain many QuoteItem arrays. Hope which makes sense. :)