- This topic has 9 replies, 3 voices, and was last updated 11 months, 2 weeks ago by .
I have created (almost ready) a new Custom Field that can keep track of multiple relationships to one and same post id.
As per another topic's requirement it would work like this:
A class attendance (CPT) has one or student (CPT) that are either present, absent or late.
There are three relationships, one for class_present_to_student, class_absent_to_student and class_late_to_student so that I can keep track of the classes the student attended, was supposed to be there but was absent and the ones that it was late.
The way the regular relationships work is a bit awkward unfortunately. You get three meta boxes, and considering that you are on the class CPT, you need to select the student(s) for each state. If you mess up, you can have the same student in both present and absent, which obviously is not wanted.
So, what I wanted to do worked up until the last part, an unfortunate miscalculation;
At present it outputs a field as follows:
[select2 student] [add student]
Albert O Present O Absent O Late [delete]
Bernhard O Present O Absent O Late [delete]
Caroline O Present O Absent O Late [delete]
[select student] is a select2-input field that queries the corresponding post_type so new students can be added to the end of the list using the [add student] button. Of course the [delete] button is used to remove the student in case it's needed.
The field itself works as expected. It registers the settings and are used to render the field when reloaded. But here's where I made a misjudgement:
I keep track of the changes in the field, the removed student ids, the ones that need an update (remove from state they're no longer in, add to new state). I meant to use those to use the API on the new Fields Class's save() callback, to MB_Relationships_API::add() and MB_Relationships_API::delete().
The problem is , I think, that because the API also writes the Meta Box values generated by the Relationships API when it saves the post. I can't seem to be able to write my values using the save callback.
Any ideas on how to temporarily disable the saving values in the meta boxes, so I can forcefully write the values to it using the API?
I can share the code in a repo if you need to see what I'm trying to do.
- You must be logged in to reply to this topic.