you filter function needs to go in your function.php file. The template file is only loaded when showing the page so the function will not exist when it needs to be called.
Basically, your filter/function needs to exist before acf_form_head()
is called.