The great Hanafi jurist, Imam al-Haskafi (Allah have mercy on him) states:
“Taking vows for the deceased like many ignorant people take money, lamps, oil, etc to the graves of the saints out of reverence is totally unlawful (haram) by consensus”.
Allama Ibn Abidin (Allah have mercy on him) commentates on the above:
“This is unlawful due to certain reasons: Firstly because, it is taking a vow for the creation (of Allah) and taking a vow for the creation is unlawful, for it (taking a vow) is worship (ibadah) and the creation is not worshiped. Secondly, the one for whom the vow is taken is deceased and a deceased does not own anything. Thirdly, if he had the belief that the deceased has an effect in one’s affairs other than Allah, then this is disbelief”. (Radd al-Muhtar, 2, 439).