I have a repeater that contains a select field.
Im using the load_field filter to dynamically populate the select fields’ choices on a custom post type.
The data comes from a custom database table and are simple date values.
The database gives me an array in the following format.
$dates = [
'2020-12-30'=> '30.12.2020',
'2020-12-31'=> '31.12.2020',
]
So far so good.
Here comes the issue that is making me lose my mind.
$field['choices'] = $dates;
return $field;
Does result in the select field having no choices at all.
However, returning the same array $dates hardcoded to the filter works perfectly as expected.
$dates_manually = [
'2020-12-30'=> '30.12.2020',
'2020-12-31'=> '31.12.2020',
];
$field['choices'] = $dates_manually;
return $field;
I tried it all. var_dump, array_diff. Everything. Its the same array. However the dynamically create $dates array results in an empty select field while the manually created one works.
I hope anybody has an idea.
I put the code I use in a GitHub Repo if that helps anybody.
Thank you very much.