Trying to work out the correct way of doing this.
My database has an Events table, and several other tables for different event types (Event_Transactions, Event_Comments etc).
The basic idea is that everything is an event, and the type of event dictates the table it joins to.
As such, Event hasOne Event* (joined on the fly depending on usage).
I want to be able to save multiple events on one form... in this case, multiple transactions...
So, I have laid out my form as such:
echo $this->Form->create('Event', array('url' => array('controller' => 'transactions', 'action' => 'deposit')));
echo $this->Form->hidden('Event.0.event_type_id', array('value' => 2));
echo $this->Form->Select('EventTransaction.0.inventory_type_id', $InventoryTypes);
echo $this->Form->Input('EventTransaction.0.amount');
echo $this->Form->end('Submit');
Javascript will be employed to add more fields, but you get the idea (second transaction will be Event.1.event_type_id and so forth)
If i do a saveAll($this->data['event']); the resulting SQL is
| 10 | START TRANSACTION | 0 | 0 | ||
| 11 | INSERT INTO `events` (`event_type_id`, `created`) VALUES (2, '2011-08-21 01:23:14') | 1 | 0 | ||
| 12 | SELECT LAST_INSERT_ID() AS insertID | 1 | 1 | 0 | |
| 13 | COMMIT |
No mention of the EventTransaction. Same happens with plain old saveAll($this->data);
If i remove the multi-row save stuff, and submit the form, the correct related information is saved.
Have I missed something here? is my form structure right?
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment