Possible auto save toggle field?

Hi there everyone,
The title says it all. Is it possible to auto save the toggle field?
I assume it could be done with a hook, right?
But how?

What do you mean? As soon as the value is toggled, it should be saved?

Nope, a hook is triggered on updating etc. not when a value is changed (if I assume that my guess under 1 is right).

your assumption is absolutely right.
how can this be done?

Good question, next :wink:.

I think you need a custom toggle field that listens to a change event and then triggers the value to be saved. May I ask why you need this?

Sure.

Well the reason is simple.
I’m using the builder plugin and have put on top off every block an toggle switch.
So every block can be published or unpublished.

I mean, do you confirm every time when you turn on the light? :face_with_raised_eyebrow:

Ah, ok, but I wonder it that would help you inside the builder? Given that you have to confirm changes to the entry, not to the toggle field.

In the end it doesn’t matter what I need it for. I think it’s completely different whether I change something or flip a switch.

An example would be the pages in kirby. I can sort them without pressing the save button each time.
Images can also be sorted without saving each time.

So the question was, is that possible with a toggle button as well?
Would be nice to have. But if it’s not possible, it might be worth a feature request.

That’s what @pixelijn already said, you need a custom toggle field.

Well, I think it does matter. Why? Because your custom toggle field might not really achieve what you want want, if you additionally want to prevent having to press the OK button on every builder field entry.

Kirby doesn’t have an autosave feature, which also doesn’t really make sense as long as we don’t have revisions. Intermediare states are saved, but in local storage, not in the content files.

Ok, now i understand better, i think?
But to be honest, for me, with my limited knowledge, there’s no way to code a custom field.