I have a channel with some fields. One of them is an on/off value (let's say toggle field type). I want to be sure that I have no more than one entry with on (or true) value for that specific field. In other words, when an entry is saved or updated, I should check value of that specific field and if it is turned on, I must turn off that field value of any previous entry which has true value for that field. What I have tried so far was:
- Trying to create a custom fieldtype by extending toggle field, but in post_save method I do not have access to current entry DB id to update other entries except the current one. The only thing I have is the saved value of the field.
- Trying database triggers, so that if the new value of the updated/inserted record is 1 (or true), update any other record which has value type of 1 (from 1/true to 0/false). It was not possible since mysql does not let you run queries on the same table as the one you are writing trigger for.
Thanks in advance