Getting a button to set a input_text value to another input_text using a template

I’m trying to set up a button that will set the value of a input_text (eg input_text.test1) to the value of another input_text (eg input_text.test2).
I have the following:

show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: input_text.set_value
  data:
    value: '{{ states("input_text.test2") }}'
  target:
    entity_id: input_text.test1

but I am getting this error in the log:

Invalid value: {{ states("input_text.test") }} (length range 0 - 10)

I’ve tested the service call on its own and it works but calling it from a button doesn’t work. Any ideas?

You cant use templates in nearly all core dashboard cards.

Put your templated service in a script and call the script as the tap action.