Closed BabalonMotherOfAbominations closed 1 year ago
Confirmed the issue here, a save()
will solve it too.
PodsAPI::save_pod_item()
handles saving the TO dataPodsField_Pick::save()
handles saving bi-directional data, saving the FROM dataPods::add()
call (or PodsAPI::save_pod_item()
as a new item) will run the TO save but the FROM save doesn't get called in that contextDigging into this further to figure out where the issue is caused from.
Fixed via df24e212792ffeb98fbb9eab3fcc8ea6e399b54d
Description
Up to PODS 2.9.9 using $pod->add($data) will properly take any values assigned in the $data array, and create a pod with the correct bi-directional fields.
Any subsequent PODS version however, will ONLY create a wp_podsrel row for the "current direction" of the relationship.
So for example, if I add a Book with 2 authors, the Book will properly be related with the authors through wp_podsrel, but the authors won't have any wp_podsrel entries of their own.
Sometimes bi-directional fields can get "stuck", and updating them through Pods -> Edit Pods fixes the issue, however this doesn't work here.
There is a possibility this issue only affects Advanced Content Types. I can't properly test this because 99% of our custom forms operate with ACTs.
Version
2.9.11.1
Testing Instructions
Screenshots / Screencast
No response
Possible Workaround
The only workaround I found is removing any relationship fields from the $data array, and doing separate calls to each one, with $pod->add_to, instead of $pod->add.
Working example:
$new_pod_id = pods( 'pod' )->add( $data ); pods('pod', $new_pod_id)->add_to('relationship_field', $relationship_field_array_of_values);
Site Health Information
Pods Package
No response