You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two CPT pods, Pod A and Pod B. Pod A has a multi-select relationship field (checkboxes) pointing to Pod B. Pod B has three records. I set up a pre-save filter for Pod A using pods_api_pre_save_pod_item, which simply determines if anything has been checked in Pod A's form:
if ( $pieces['fields']['pod_b']['value'] == '' )
If no checkboxes are selected in Pod A's form, the if statement returns true.
I duplicated this setup, this time using ACT pods. The if statement returns false. Here's the pre-save var_dump output of the $pieces['fields']['pod_b']['value'] array:
As you can see, while the CPT pod returns an array with only keys, the ACT pod's array also contains a value ("0"). This makes validating $pieces['fields']['pod_b']['value'] more complicated, since the array has a value even when no checkboxes are selected.
Also, notice how the ACT pod adds a "0" record to the array whenever the first option is unchecked, resulting in an unexpected number of rows.
The text was updated successfully, but these errors were encountered:
chilledfresh
changed the title
Strange behavior with ACT pod relationship field value array
Unexpected behavior with ACT pod relationship field value array
Dec 11, 2014
That should fix the issue. This doesn't happen if the format is 'Checkboxes' or 'Autocomplete'. On a CPT there is no data being passed in the POST for that field, in an ACT the field is being passed as empty '' which pods is translating to an empty item. Which is legit behavior on the pods side.
I suspect that the WordPress post side is unsetting empty values so it doesn't pass them along, but I didn't trace all the js code to see where it is happening
I have two CPT pods, Pod A and Pod B. Pod A has a multi-select relationship field (checkboxes) pointing to Pod B. Pod B has three records. I set up a pre-save filter for Pod A using
pods_api_pre_save_pod_item
, which simply determines if anything has been checked in Pod A's form:if ( $pieces['fields']['pod_b']['value'] == '' )
If no checkboxes are selected in Pod A's form, the
if
statement returnstrue
.I duplicated this setup, this time using ACT pods. The
if
statement returnsfalse
. Here's the pre-savevar_dump
output of the$pieces['fields']['pod_b']['value']
array:Custom Post Type: nothing checked
array(3) { [0]=> int(122) [1]=> int(123) [2]=> int(124) }
Custom Post Type: all options checked
array(3) { [0]=> string(3) "122" [1]=> string(3) "123" [2]=> string(3) "124" }
Custom Post Type: second and third option checked
array(2) { [1]=> string(3) "123" [2]=> string(3) "124" }
Advanced Content Type: nothing checked
array(1) { [0]=> string(1) "0" }
Advanced Content Type: all options checked
array(3) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(1) "3" }
Advanced Content Type: second and third option checked
array(3) { [0]=> string(1) "0" [1]=> string(1) "2" [2]=> string(1) "3" }
Advanced Content Type: third option checked
array(2) { [0]=> string(1) "0" [2]=> string(1) "3" }
As you can see, while the CPT pod returns an array with only keys, the ACT pod's array also contains a value ("0"). This makes validating
$pieces['fields']['pod_b']['value']
more complicated, since the array has a value even when no checkboxes are selected.Also, notice how the ACT pod adds a "0" record to the array whenever the first option is unchecked, resulting in an unexpected number of rows.
The text was updated successfully, but these errors were encountered: