Can you clarify what you are passing that PHP into?
You should try out using our find() method on the Pods object: https://docs.pods.io/code/pods/find/
I’m passing it into form().
Here’s the complete bit of code that might clarify what I’m attempting.
$charpod = pods( 'characters', $charid )
$fields = array(
'group_membership' => array( 'description' => 'MATCH TO OLD GROUP!
This will activate the new system for this character.','customized_where' => 'secret.meta_value != 1' ),
'rank_assignment' => array( 'description' => 'MATCH TO OLD RANK!
This will activate the new system for this character.' )
);
echo $charpod->form($fields);
Specifically, I want to be able to set the field setting “customized WHERE” in the advanced setting for a relationship field. But I’m not sure there’s a way to accomplish this dynamically based on what version of the form the end user is sent to?
-
This reply was modified 1 year, 9 months ago by
kitsufox.
@kitsufox Parameters for a relationship field do not have a where argument because a query is not run — the specific IDs are stored.
However, one can override what items display as options in a relationship field by adding a query using the pods_field_pick_data filter or pods_field_pick_data_ajax filter
This filter will run for all relationship fields on frontend and backend, so one can either attach the filter based on admin or frontend context, or modify behavior based on the field $name or other information passed to the function.
An example of using the first filter:
<?php
add_filter(
'pods_field_pick_data',
function( $data, $name, $value, $options, $pod, $id ) {
error_log(
print_r(
[
'info' => sprintf( 'RELATIONSHIP FIELD named %s', $name ),
'$data' => $data,
'$name' => $name,
'$value' => $value,
'$options' => $options,
'$id', => $id,
]
true
)
);
return $data;
},
10,
6
);
…where return $data sends the data to the field unmodified in all cases, while print_r() saves information for every relationship field that ran the filter to the PHP error log. $pod was left out of logging, as it would be an instance of the Pods object, which contains a lot of information.