Re: Still having trouble with saving BelongsToMany data
No, it is not related to that issue. Do you have any idea of what cake version you were using before updating? On Thursday, March 12, 2015 at 4:37:50 AM UTC+1, Joe T. wrote: i absolutely cannot believe this: it's broken again. i haven't done anything but run *composer update* and i'm back to losing the [_joinData][value] from request data when i patch the entity, so the joint table record inserts NULL. It DOES insert, but the _joinData is GONE from the entity. Is there any chance it's related to this issue? https://github.com/cakephp/cakephp/issues/6050 Now what? On Sunday, 8 March 2015 00:40:49 UTC-5, Joe T. wrote: Kevin, i'm so grateful for all your effort ideas. i don't fully grasp conditional validation yet, though i suspect i will have to address that sooner or later. When i re-baked the models, -requirePresence('field_name', 'create') is already set by default in *AttributesTable*, so that got me nowhere. i also tried making a one-stop association like so: input type=checkbox name=listings_attributes[3][attribute_id] value= 1 input type=text name=listings_attributes[3][value] !-- Off-street -- Then in the Controller: $listing = $this-Listings-patchEntity($listing, $this-request-data, [ 'associated' = ['ListingsAttributes']]); It didn't produce any entity errors, but it didn't save the ListingsAttributes record, either. The data never makes it to the entity. What i ultimately had to do (though it feels *really* dirty) was your initial suggestion: add all the *attribute* fields as hidden inputs. However, that added another problem: ALL the attributes were being submitted because the hidden fields were enabled for POSTing. So i had to tweak the Javascript that presents a text input for the join data (value) to also toggle the [*disabled*] property of all the hidden inputs for a given Attribute check box. i'm *FINALLY* getting data in the ListingsAttributes table. i'm not a fan of doing it this way, but i'll have to live with it for now. i really think there should be an option to tell the ORM to stop the save at the join table, rather than always trying to update the linked record in the associated table. If there is a way to do this with the ORM's save options, it doesn't appear to be documented. Obviously, i followed the documentation to the letter, but my assumption of its behavior was wrong. Thanks again! -joe On Saturday, 7 March 2015 13:21:56 UTC-5, heavyKevy wrote: I thought of one more option... You can specify a separate validation specifically for adding the listing attributes such that the usual validation continues to be used and work as it was and the new validation works only for this instance. The documentation has all of the information on how to do this should you decide to choose this option... -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Still having trouble with saving BelongsToMany data
Joe, I tried doing a composer update and test and it is not broken for me. https://www.dropbox.com/s/7tjqy3i5z9hnngc/src.zip?dl=0 This is all of the source that I threw together to get it to work. The example is far from perfect in that I don't have all of the fields that you have in my tables, just the bare necessities in order to test and make it work. Also, all 4 of the listingsAttributes have to be filled in currently or it does not save, so the validation needs a bit of work, but I verified this this code does still work after updating. Could it be that yours still works if you specify a value for every ListingsAttribute? Hope something here helps... --Kevin -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Still having trouble with saving BelongsToMany data
Somehow, i'm totally unsurprised. _ i'll take a look at the sample you uploaded tonight. You're right, without some UI controls, all the Attributes would require values for the Submit to save successfully. i have Javascript toggling the [disabled] property on the *_joinData.value* and hidden *attribute* inputs. That way, unless the user specifically checks the Attribute to enable it, its inputs won't POST. i've compared my files to what i did when (i *swear*) it was working, and don't see any functional changes, but maybe i need to back up a step in my own code. This has been really frustrating because i *know* other people are doing this successfully, so it's hard to understand what's so radically different about me. DIGRESSION i'm still hoping for some explanation from the developers why this is necessary. i've only managed to get this working at all by adding unnecessary hidden inputs to my interface adding Javascript to handle whether they're enabled for the Submit. All i *want* to do is grab an ID from the foreign table (Attributes), add a value for the joint table (ListingsAttributes), and save the Listings and ListingsAttributes records. There's no need to touch the Attributes table, but it fails unless i provide all that data. i can see how it's useful for some scenarios (Articles/Tags) where it's all data you'd typically create/change simultaneously. But even the Students/Courses example doesn't sit right in my mind. You don't generally create Courses at the same time you create Students. You create the links between them with the additional data (grade, attendance, etc.). But according to everything happening here, when you create a Student want to link it to Courses, you have to provide ALL the data for every Course, else the save will fail. On Thursday, 12 March 2015 09:19:53 UTC-4, heavyKevy wrote: Joe, I tried doing a composer update and test and it is not broken for me. https://www.dropbox.com/s/7tjqy3i5z9hnngc/src.zip?dl=0 This is all of the source that I threw together to get it to work. The example is far from perfect in that I don't have all of the fields that you have in my tables, just the bare necessities in order to test and make it work. Also, all 4 of the listingsAttributes have to be filled in currently or it does not save, so the validation needs a bit of work, but I verified this this code does still work after updating. Could it be that yours still works if you specify a value for every ListingsAttribute? Hope something here helps... --Kevin -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Testing AppModel by core Cake tests
Hello Everyone, I have changed standart behaviour for models in my AppModel, and i'm running core CakePHP tests (testsuite core Model/Model), but models in tests not uses my AppModel. How can I test my AppModel with tests from cake? Thank you. -- Dmitry Romanov -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Still having trouble with saving BelongsToMany data
Thank you José, i'll try that tonight as well. On Thursday, 12 March 2015 12:12:05 UTC-4, José Lorenzo wrote: If you want to create first and then link follow the instructions in this section: http://book.cakephp.org/3.0/en/orm/saving-data.html#saving-belongstomany-associations Specifically where it shows the calls to `Users-link($article, [$user])` On Thursday, March 12, 2015 at 3:09:54 PM UTC+1, Joe T. wrote: Somehow, i'm totally unsurprised. _ i'll take a look at the sample you uploaded tonight. You're right, without some UI controls, all the Attributes would require values for the Submit to save successfully. i have Javascript toggling the [disabled] property on the *_joinData.value* and hidden *attribute* inputs. That way, unless the user specifically checks the Attribute to enable it, its inputs won't POST. i've compared my files to what i did when (i *swear*) it was working, and don't see any functional changes, but maybe i need to back up a step in my own code. This has been really frustrating because i *know* other people are doing this successfully, so it's hard to understand what's so radically different about me. DIGRESSION i'm still hoping for some explanation from the developers why this is necessary. i've only managed to get this working at all by adding unnecessary hidden inputs to my interface adding Javascript to handle whether they're enabled for the Submit. All i *want* to do is grab an ID from the foreign table (Attributes), add a value for the joint table (ListingsAttributes), and save the Listings and ListingsAttributes records. There's no need to touch the Attributes table, but it fails unless i provide all that data. i can see how it's useful for some scenarios (Articles/Tags) where it's all data you'd typically create/change simultaneously. But even the Students/Courses example doesn't sit right in my mind. You don't generally create Courses at the same time you create Students. You create the links between them with the additional data (grade, attendance, etc.). But according to everything happening here, when you create a Student want to link it to Courses, you have to provide ALL the data for every Course, else the save will fail. On Thursday, 12 March 2015 09:19:53 UTC-4, heavyKevy wrote: Joe, I tried doing a composer update and test and it is not broken for me. https://www.dropbox.com/s/7tjqy3i5z9hnngc/src.zip?dl=0 This is all of the source that I threw together to get it to work. The example is far from perfect in that I don't have all of the fields that you have in my tables, just the bare necessities in order to test and make it work. Also, all 4 of the listingsAttributes have to be filled in currently or it does not save, so the validation needs a bit of work, but I verified this this code does still work after updating. Could it be that yours still works if you specify a value for every ListingsAttribute? Hope something here helps... --Kevin -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Still having trouble with saving BelongsToMany data
If you want to create first and then link follow the instructions in this section: http://book.cakephp.org/3.0/en/orm/saving-data.html#saving-belongstomany-associations Specifically where it shows the calls to `Users-link($article, [$user])` On Thursday, March 12, 2015 at 3:09:54 PM UTC+1, Joe T. wrote: Somehow, i'm totally unsurprised. _ i'll take a look at the sample you uploaded tonight. You're right, without some UI controls, all the Attributes would require values for the Submit to save successfully. i have Javascript toggling the [disabled] property on the *_joinData.value* and hidden *attribute* inputs. That way, unless the user specifically checks the Attribute to enable it, its inputs won't POST. i've compared my files to what i did when (i *swear*) it was working, and don't see any functional changes, but maybe i need to back up a step in my own code. This has been really frustrating because i *know* other people are doing this successfully, so it's hard to understand what's so radically different about me. DIGRESSION i'm still hoping for some explanation from the developers why this is necessary. i've only managed to get this working at all by adding unnecessary hidden inputs to my interface adding Javascript to handle whether they're enabled for the Submit. All i *want* to do is grab an ID from the foreign table (Attributes), add a value for the joint table (ListingsAttributes), and save the Listings and ListingsAttributes records. There's no need to touch the Attributes table, but it fails unless i provide all that data. i can see how it's useful for some scenarios (Articles/Tags) where it's all data you'd typically create/change simultaneously. But even the Students/Courses example doesn't sit right in my mind. You don't generally create Courses at the same time you create Students. You create the links between them with the additional data (grade, attendance, etc.). But according to everything happening here, when you create a Student want to link it to Courses, you have to provide ALL the data for every Course, else the save will fail. On Thursday, 12 March 2015 09:19:53 UTC-4, heavyKevy wrote: Joe, I tried doing a composer update and test and it is not broken for me. https://www.dropbox.com/s/7tjqy3i5z9hnngc/src.zip?dl=0 This is all of the source that I threw together to get it to work. The example is far from perfect in that I don't have all of the fields that you have in my tables, just the bare necessities in order to test and make it work. Also, all 4 of the listingsAttributes have to be filled in currently or it does not save, so the validation needs a bit of work, but I verified this this code does still work after updating. Could it be that yours still works if you specify a value for every ListingsAttribute? Hope something here helps... --Kevin -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Still having trouble with saving BelongsToMany data
Unfortunately no, i don't know what hash i was on before i updated. It would be one of the untagged RC2 commits within the last couple weeks i was trying to get this to work. i'm willing to backtrack, though, to try to find out. Suggestions how i would do that? Looking at the PR list on Github comparing that with the timeline of this thread, i'd say it's *likely* something within the last 4-5 PRs: March 2: https://github.com/cakephp/cakephp/pull/5991 March 6: https://github.com/cakephp/cakephp/pull/6021 March 8: https://github.com/cakephp/cakephp/pull/6030 March 10: https://github.com/cakephp/cakephp/pull/5905 The most recent PR was March 11 fixing a link in a comment. Not a likely candidate. ;) If you want me to try going backward prior to any of those, let me know how. -joe On Thursday, 12 March 2015 04:29:17 UTC-4, José Lorenzo wrote: No, it is not related to that issue. Do you have any idea of what cake version you were using before updating? On Thursday, March 12, 2015 at 4:37:50 AM UTC+1, Joe T. wrote: i absolutely cannot believe this: it's broken again. i haven't done anything but run *composer update* and i'm back to losing the [_joinData][value] from request data when i patch the entity, so the joint table record inserts NULL. It DOES insert, but the _joinData is GONE from the entity. Is there any chance it's related to this issue? https://github.com/cakephp/cakephp/issues/6050 Now what? On Sunday, 8 March 2015 00:40:49 UTC-5, Joe T. wrote: Kevin, i'm so grateful for all your effort ideas. i don't fully grasp conditional validation yet, though i suspect i will have to address that sooner or later. When i re-baked the models, -requirePresence('field_name', 'create') is already set by default in *AttributesTable*, so that got me nowhere. i also tried making a one-stop association like so: input type=checkbox name=listings_attributes[3][attribute_id] value =1 input type=text name=listings_attributes[3][value] !-- Off-street -- Then in the Controller: $listing = $this-Listings-patchEntity($listing, $this-request-data, ['associated' = ['ListingsAttributes']]); It didn't produce any entity errors, but it didn't save the ListingsAttributes record, either. The data never makes it to the entity. What i ultimately had to do (though it feels *really* dirty) was your initial suggestion: add all the *attribute* fields as hidden inputs. However, that added another problem: ALL the attributes were being submitted because the hidden fields were enabled for POSTing. So i had to tweak the Javascript that presents a text input for the join data (value) to also toggle the [*disabled*] property of all the hidden inputs for a given Attribute check box. i'm *FINALLY* getting data in the ListingsAttributes table. i'm not a fan of doing it this way, but i'll have to live with it for now. i really think there should be an option to tell the ORM to stop the save at the join table, rather than always trying to update the linked record in the associated table. If there is a way to do this with the ORM's save options, it doesn't appear to be documented. Obviously, i followed the documentation to the letter, but my assumption of its behavior was wrong. Thanks again! -joe On Saturday, 7 March 2015 13:21:56 UTC-5, heavyKevy wrote: I thought of one more option... You can specify a separate validation specifically for adding the listing attributes such that the usual validation continues to be used and work as it was and the new validation works only for this instance. The documentation has all of the information on how to do this should you decide to choose this option... -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.