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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to