With the view you created there was multiple issues as when you filter with the post relationship as it return multiple values as well as issue with nested views shortcodes.
As a more efficient workaround that should not cause any issues even in future:
I've added the following shortcode to "Custom Code" section offered by Toolset with code snippet "toolset-custom-code":
=> hidden link
add_shortcode('get_generic_select_options', 'func_get_json_for_generic_select');
function func_get_json_for_generic_select() {
global $post;
$localities_ids = toolset_get_related_posts(
$post->ID,
'leerling-lokatie',
'parent',
999,
0,
array(),
'post_id',
'child'
);
if(!empty($localities_ids)) {
$workshop_ids = array();
foreach($localities_ids as $k=>$v):
$workshop_ids[] = toolset_get_related_posts(
$v,
'lokatie-workshop',
'parent',
999,
0,
array(),
'post_id',
'child'
);
endforeach;
}
$workshop_ids = join(",",array_merge(...array_values($workshop_ids)));
$workshops = do_shortcode('[wpv-view name="leerling-inschrijving-workshops-options" ids="'.$workshop_ids.'"]');
return trim($workshops);
}
The above snipped will find the related localities based on the current post and then based on the related localities of current post it will find all the related workshops IDs and we pass those found workshop IDs to view "leerling-inschrijving-workshops-options" where I've changed the query filter for that view to filter by post ID:
=> hidden link
Post ID filter
Include only posts with IDs set by the View shortcode attribute "ids" eg. [wpv-view name="view-name" ids="1"]
At last I've passed the above shortcode to the generic field:
<div class="form-group col-md-2">
<label for="%%FORM_ID%%_workshop-leerling-locatie">[cred_i18n name='workshop-leerling-locatie-label']Workshop:[/cred_i18n]</label>
</div>
<div class="col-md-8">
[cred_generic_field type='select' field='workshop-leerling-locatie' class="form-control"]
{
"required":1,
"options":[ [get_generic_select_options] ]
}
[/cred_generic_field]
</div>
I can see it displays the workshops with select dropdown: hidden link
Can you please confirm it works as expected.