Un-favourite a record from the Favourite list

Hi

I have created a Favourites screen with a linked list/collection which works fine.
I have added a toggle component (favourite) so users could un-favourite a record, to narrow the list down.


*the selection under ‘What does this toggle’ is empty.

However, when the records get added to the Favourite list, by default the toggle (heart icon) is off.

1. How can I make the heart toggle to be ON by default?

2. How can I remove the record from the list when a user de-select the toggle?

Hi @Manoux,

You have a Many to Many relationship with that collection and the Users collection right?

This Docs should help here! :

And this video in this topic will help here too! : Some Tips and Tricks by this Semi Noob! 😅 ( Tip 24 )

Thank you

1 Like

Hi @Manoux ,

Adding what @dilon_perera has replied.

  1. You can choose to make unfavorite list instead of favorite list, so by default all users have favorite this list, this is one way of doing this, if you choose this way, you can look up komun template here,
    Free Template - Komun for Community Support - In Progress

The Users and Projects collections have many-to-many relationship, it is the 3rd choice when adding relationship.

Here is projects collection linked to users and called unsubscribers, so at the beginning there will be no unsubscribers, meaning all users are subscribed to this.

Here is from users collection.

When showing project unsubscribers,

So the perspective is reverse, in your case, if you want users favorite the list by default, there is no need to update record, because by default all users are subscriber, and by the same logic if they want to unfavorite the list, they need to do something which is updating project record with add logged in user. (creating many-to-many relationship is by updating action and add or remove in the related field).

Let me know if I need to clarify further.

Hi @Yongki and @dilon_perera

Thanks a lot for your replies. I have watched the video, but I think my setup is a bit different so I am not sure if this is going to work. Maybe I should have mentioned this at the beginning.

The way that records are getting created in my Favourite collection is via the Favourite toggle on my Cat and Dog details screens via the ‘Create’ action. So have no ‘all’ list only the Favourites list/collection
And this Favourite collection I added into my User collection (M2M) and into my Cats and Dogs collections (also M2M)

Is it even possible to achieve what I want with this setup? Or do I have to rebuild this?

Thanks a lot!

When you use toggle in many-to-many, there is no need to create new record in another collection (favourites)

The toggle component will do and update action and add / remove by itself.

So in the list for your favourites, select filter that is many-to-many, be sure you have that relationship.

1 Like

Oh you are using a joint table! Then you need a icon with a list to delete that record in the collection. But in here you don’t need list with icon and you can have a icon in the Favorites list and add a Delete current favorite action there! But the easiest way is to use a Many to Many relationship! ( then the toggle is doing this automatically for you like Yongki mentioned! )

Made a video : Favorite Pets.mp4 - Google Drive

You can check the app too : Favorite Pets

1 Like

Thanks so much for your help. I will use your video as guidance and hopefully manage to make it work.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.