has_many relations deleted on save

edited October 2015 in Bug Reports

I have a strange behaviour. I have a missions_model with a has_many relationship to mission_images_model. mission_images_model has the vice-versa belongs_to relationship to missions_model.

In my backend the assignment of mission_images to mission is done via the mission_images_model. IN the missions_Model I changed the type of mission_images to hidden.

Now I create a mission and then assigne some images via mission_images. Everything works fine, the relations are stored in relationship table.

Now I edit the mission and save it. Then unfortunatly and strangely the relations in the relationship table are deleted.
Do you have any idea why this is happening?

If I do not change the type of mission_images to hidden everything works fine. Is there another possibility not to show the has_Many relationship in the missions_model?



  • edited 11:41AM
    Try adding the following property to your model first to see if this prevents the issue:
    protected $clear_related_on_save = FALSE;
  • edited 11:41AM
    did it. Thanks!
Sign In or Register to comment.