Everyone is required to complete a public health form online before they depart. You can only answer the health questions 48 hours before your arrival date in Spain. This is only for people flying to Spain
This applies to everyone entering Spain from another country. This law came into force on 1st July 2020.
You can get the form here https://www.spth.gob.es/ or via the app SpTH, available for Android and Apple, but only in Spanish. When you have filled in the form you will get a QR code which you have to show when you arrive in Spain.
When you get to Spain you have to have your temperature taken