Checkboxes Field That Updates Options When Title/Field Changes

I have a checkboxes field that uses a query to list its options. However, that query is dependent on the contents of the title and text field (it basically does some text parsing to try and figure out suggested tags).

What I would like to do those is have the checkboxes field update automatically when I save a page. Right now, after I make title/text changes, I have to refresh the panel page for the options to be reflected.

You could probably use a hook to update the field, but i still don’t think it will be seen until you reload the page. I think the page save just saves the data without refreshing the page.

Are these tags for SEO purposes, like keywords to use in the written copy, or are they the other tags for categorising pages, like a tag cloud? Would it be enough to get the tags from other pages? Im betting your using similar things, or a finite list, so these are probably already stored in other pages?

I think it works with hooks as long as your browser’s cache is off. You’d have to test this but what I’ve seen from hooks if I remember rightly, is that the changes are immediately reflected in the page without reloading.

I think you’re correct that if I was merely selecting existing options, the Panel would correctly reflect that after a save.

However, I don’t want to automatically “select” tags. I merely want them to be shown as options.

When the content gets saved, the Panel receives a copy of all the saved data and should reflect that for the appropriate fields. What it doesn’t seem to do is be able to realize that the query driving the checkboxes’ options has changed as part of the content change.

To answer @jimbobrjames question: the “tags” are for basically tying together different articles on our website, so we can suggest articles from other articles if they’re about the same topic. I’d be tempted to just do this all automatically with a hook, but there are definitely going to be times where this is wrong and I want to be able to control this manually. The checkboxes query just goes through the content and tries to guess which tags are relevant, so we’re not searching through hundreds of potential options.

What if instead of trying to update the checkboxes field you store these tags in a tags field in your hook. The content of that field would then update after saving and the user could just remove the unwanted tags? (Note quite sure I fully get your workflow, though).

That’s a good suggestion. I think I might ultimately move to something like that.

It’s just a bit tricky to try and determine when a good time to update that field is. I don’t think I would really want it to be after every content update (because then manually removed fields would likely come back after re-saving the page).

Maybe when changing the status from draft to listed/unlisted would be the “best” time, since that doesn’t happen very often.