This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I have a working model 'link' which belongs to many 'linkgroups' with a pivot table. When I access the route /plugin/links and create a link and assign it a link group everything works as expected (the relationship is created and the pivot is updated) I run into problems when this relationship is called via relationRender() from another controller. I get the popup as expected, I get the checkboxes as expected, but on save the pivot table is not updated so the 'link' is not related to the 'linkgroup'. Can anybody help me understand why this is happening?
Thanks
Sorry to bump this but I still have no answer here or elsewhere. I am sure this isn't a bug and has to do with my faulty implementation but I cannot understand why a model would work standalone but fail when called from within a separate but related controller. To clarify: Product is the master model/ controller Product has many links Links belong to many linkgroups
/plugin/links works correctly and can assign link to linkgroups /plugin/products only partially works in that a link is assigned to the product but although the form appears correctly, links are NOT assigned to their linkgroup (pivot table does not update).
Cheers Rob
It may be due to Deferred binding, the changes won't be committed until the parent model is saved. Without seeing your complete code it is difficult to diagnose what is happening.
It's really difficult to post my code at the moment, which is not helpful I know. Only thing I can really contribute is that the problem seems to be related to using the Update button on the popup form as opposed to the save button when accessing the link model directly. I don't see any entries in the deferred binding table and as far as I can see the relationship is initialised properly. Do I need to write a beforeSave() to make this relationship work. I cannot find any examples anywhere that use relationRender() to do what I want ie Product has many links Link has many Link groups I don't know if this is helpful, but it demonstrates where I am stuck: http://postimg.org/image/jmo9pr569 basically, checking the boxes does no good at all, the link is created successfully, but the Link group doesn't work. Incidentally, if I go via /links and make the relationship between a link and the group, that is reflected in my popup form, but again, changing it doesn't do anything
Last updated
Look at how Locations are managed in the Users plugin. This works well and uses relationRender().
I find it hard to understand what you are trying to do but it sounds more complicated than just using a relationRender though.
Thanks axomat. It's actually not as complicated as I've made it for myself. My problem was with mass assignment. It wasn't clear to me that I could/should add the related model name to the fillable array. I thought this was just for columns on the model table but apparently not. I'm new to October and Laravel so I will run into problems like this sometimes.
We are all new to October ;-) and that tip about related model and fillable will be useful thanks.
1-8 of 8