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
We have a client requirement where one dropdown needs to filter the items available in the second. They also need the options very specifically sorting based on an order they enter themselves in the admin. These fields are all ACF fields.
e.g. Selecting an option in Competition here will need to filter the options available in Section
Looking at the filters available for ACP, this almost seems like it's possible with acp/filtering/dropdown_args.
add_filter('acp/filtering/dropdown_args', function (array$data, \ACA\ACF\Column$column) {
$activeColumns = [];
if (!empty($_GET['acp_filter']) && !empty($_GET['layout'])) {
foreach ($_GET['acp_filter'] as$columnName => $value) {
$activeColumns[$columnName] = [
'column' => ac_get_column($columnName, $_GET['layout']),
'value' => $value,
];
}
}
// Restrict by active competitionif ($column->get_meta_key() === 'section') {
foreach ($activeColumnsas$activeColumn) {
if ($activeColumn['column']->get_meta_key() === 'competition') {
$data['options'] = array_filter($data['options'], function ($item) use ($activeColumn) {
returnget_post_meta($item, 'competition', true) === $activeColumn['value'];
}, ARRAY_FILTER_USE_KEY);
}
}
}
return$data;
});
However the first thing that happens on page load is that an ajax request to acp_update_filtering_cache which overwrites the custom data and ordering we just applied.
Is there some way of doing what we need, without resorting to developing custom Dropdown field types?
The text was updated successfully, but these errors were encountered:
Hi,
We have a client requirement where one dropdown needs to filter the items available in the second. They also need the options very specifically sorting based on an order they enter themselves in the admin. These fields are all ACF fields.
e.g. Selecting an option in
Competition
here will need to filter the options available inSection
Looking at the filters available for ACP, this almost seems like it's possible with
acp/filtering/dropdown_args
.However the first thing that happens on page load is that an ajax request to
acp_update_filtering_cache
which overwrites the custom data and ordering we just applied.Is there some way of doing what we need, without resorting to developing custom Dropdown field types?
The text was updated successfully, but these errors were encountered: