Advanced Custom Fields – Displays ACF if the parent page has a specific template

I'm trying to create a new ACF rule to display the fields when the parent page has a specific template name. Here is my current attempt:

add_filter ('acf / location / rule_types', & # 39; acf_location_rules_types & # 39;);
acf_location_rules_types function ($ choice) {

$ choice['Parent']['parent_template']    = & # 39; Parent model & # 39 ;;

return choices $;

}

add_filter (acf / location / rules_values ​​/ parent_template & # 39; acf_location_rules_values_parent_template & # 39;);
function acf_location_rules_values_parent_template ($ choices) {

$ templates = get_page_templates ();

if ($ models) {
foreach ($ templates as $ template_name => $ template_filename) {

$ choice[ $template_name ] = $ template_name;

}
}

return choices $;
}

add_filter (& acf / location / rule_match / parent_template & # 39 ;, & # 39; acf_location_rules_match_parent_template & # 39 ;, 10, 3);
function acf_location_rules_match_parent_template ($ match, $ rule, $ options) {

$ selected_template = $ rule['value'];

global $ post;
$ template = get_page_template_slug ($ post-> post_parent);

if ($ rule['operator'] == "==") {

$ match = ($ selected_template == $ template);

} elseif ($ rule['operator'] == "! =") {

$ match = ($ selected_template! = $ template);

}

return $ match;
}

I think the problem is the way I'm trying to get a parent page template for the current page. Can I even get a parent page template in a connection function in function.php?