Hi people.. I have a trouble on the saveAssociated method, please if some onw could give me a help, my problem is that the the saveAssociated method is saying me that the model couldnt be saved, thanks
I am attaching the code and the bin link http://bin.cakephp.org/view/1231114400 1. /** 2. Estimation Model 3. **/ 4. 5. App::uses('AppModel', 'Model'); 6. 7. /** 8. * Estimation Model 9. * 10. * @property Referal $Referal 11. * @property Invoicing $Invoicing 12. * @property Contract $Contract 13. * @property SalePackage $SalePackage 14. */ 15. class Estimation extends AppModel { 16. 17. /** 18. * Validation rules 19. * 20. * @var array 21. */ 22. public $validate = array <http://www.php.net/array>( 23. 'referal_id' => array <http://www.php.net/array>( 24. 'numeric' => array <http://www.php.net/array>( 25. 'rule' => array <http://www.php.net/array>('numeric'), 26. ), 27. ), 28. 'invoicing_id' => array <http://www.php.net/array>( 29. 'numeric' => array <http://www.php.net/array>( 30. 'rule' => array <http://www.php.net/array>('numeric'), 31. ), 32. ), 33. 'vehicles_from' => array <http://www.php.net/array>( 34. 'numeric' => array <http://www.php.net/array>( 35. 'rule' => array <http://www.php.net/array>('numeric'), 36. ), 37. ), 38. 'vehicles_to' => array <http://www.php.net/array>( 39. 'numeric' => array <http://www.php.net/array>( 40. 'rule' => array <http://www.php.net/array>('numeric'), 41. ), 42. ), 43. 'expiration_days' => array <http://www.php.net/array>( 44. 'numeric' => array <http://www.php.net/array>( 45. 'rule' => array <http://www.php.net/array>('numeric'), 46. ), 47. ), 48. 'active' => array <http://www.php.net/array>( 49. 'boolean' => array <http://www.php.net/array>( 50. 'rule' => array <http://www.php.net/array>('boolean'), 51. ), 52. ), 53. 'status' => array <http://www.php.net/array>( 54. 'boolean' => array <http://www.php.net/array>( 55. 'rule' => array <http://www.php.net/array>('boolean'), 56. ), 57. ), 58. ); 59. 60. //The Associations below have been created with all possible keys, those that are not needed can be removed 61. 62. /** 63. * belongsTo associations 64. * 65. * @var array 66. */ 67. public $belongsTo = array <http://www.php.net/array>( 68. 'Referal' => array <http://www.php.net/array>( 69. 'className' => 'Referal', 70. 'foreignKey' => 'referal_id', 71. 'conditions' => '', 72. 'fields' => '', 73. 'order' => '' 74. ), 75. 'Invoicing' => array <http://www.php.net/array>( 76. 'className' => 'Invoicing', 77. 'foreignKey' => 'invoicing_id', 78. 'conditions' => '', 79. 'fields' => '', 80. 'order' => '' 81. ) 82. ); 83. 84. /** 85. * hasMany associations 86. * 87. * @var array 88. */ 89. public $hasMany = array <http://www.php.net/array>( 90. 'Contract' => array <http://www.php.net/array>( 91. 'className' => 'Contract', 92. 'foreignKey' => 'estimation_id', 93. 'dependent' => false, 94. 'conditions' => '', 95. 'fields' => '', 96. 'order' => '', 97. 'limit' => '', 98. 'offset' => '', 99. 'exclusive' => '', 100. 'finderQuery' => '', 101. 'counterQuery' => '' 102. ), 103. 'SalePackage' => array <http://www.php.net/array>( 104. 'className' => 'SalePackage', 105. 'foreignKey' => 'estimation_id', 106. 'dependent' => false, 107. 'conditions' => '', 108. 'fields' => '', 109. 'order' => '', 110. 'limit' => '', 111. 'offset' => '', 112. 'exclusive' => '', 113. 'finderQuery' => '', 114. 'counterQuery' => '' 115. ) 116. ); 117. 118. } 119. 120. 121. /** 122. Method for save data 123. **/ 124. public function admin_add() { 125. if ($this->request->is('post')) { 126. //$this->Estimation->create(); 127. debug($this->request->data); 128. if ($this->Estimation->saveAssociated($this->request->data)) { 129. $this->Session->setFlash(__('The estimation has been saved')); 130. /*if (isset($this->request->data['Estimation']['new']) && $this->request->data['Estimation']['new']) { 131. $this->redirect(array('controller' => 'estimations', 'action' => 'add')); 132. } else { 133. $this->redirect(array('controller' => 'estimations', 'action' => 'view', $this->Estimation->id)); 134. }*/ 135. } else { 136. $this->Session->setFlash(__('The estimation could not be saved. Please, try again.')); 137. } 138. } 139. 140. 141. /** 142. The result of the array debug before saving 143. **/ 144. array <http://www.php.net/array>( 145. 'Referal' => array <http://www.php.net/array>( 146. 'biz_name' => 'EL BANANERO', 147. 'doc_type_id' => '3', 148. 'doc_number' => '2141232', 149. 'first_name' => 'RICARDO', 150. 'last_name' => 'OVIEDO', 151. 'address' => 'Arequipa', 152. 'email' => '[email protected]', 153. 'phone' => '', 154. 'mobile' => '' 155. ), 156. 'Estimation' => array <http://www.php.net/array>( 157. 'date' => '2012-07-18', 158. 'invoicing_id' => '1', 159. 'vehicles_from' => '9', 160. 'vehicles_to' => '10', 161. 'expiration_days' => '10', 162. 'comments' => 'Esto es una prueba', 163. 'sub_total' => '40', 164. 'taxes' => '7.2', 165. 'total' => '47.2', 166. 'new' => '0' 167. ), 168. 'SalePackage' => array <http://www.php.net/array>( 169. (int) 0 => array <http://www.php.net/array>( 170. 'product_id' => '1', 171. 'description' => 'PRODUCTO UNO', 172. 'price_package' => '10' 173. ), 174. (int) 1 => array <http://www.php.net/array>( 175. 'product_id' => '1', 176. 'description' => 'PRODUCTO UNO', 177. 'price_package' => '10' 178. ), 179. (int) 2 => array <http://www.php.net/array>( 180. 'product_id' => '1', 181. 'description' => 'PRODUCTO UNO', 182. 'price_package' => '10' 183. ), 184. (int) 3 => array <http://www.php.net/array>( 185. 'product_id' => '1', 186. 'description' => 'PRODUCTO UNO', 187. 'price_package' => '10' 188. ) 189. ) 190. ) -- Carlos Eduardo Sotelo Pinto GNU Linux Admin | PHP Senior Web Developer MObil: RPC (Claro)+51, 958194614 http://www.carlossotelo.com Skype: csotelop Yahoo: csotelop MSN: [email protected] GTalk: [email protected] GPG FP:697E FAB8 8E83 1D60 BBFB 2264 9E3D 5761 F855 4F6B GNULinux RU #379182 || GNULinux RM #277661 -- 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
