67
Lifecycle hooks for Components
Ernest
Hi everyone! I think it would be very useful to have lifecycle hooks for Components, just as it is today for Collection Types.
Francesc Perez
Do this, and work a little bit :)
Sem Limi
Agree, I really really need my previous component data to be visible in the beforeUpdate lifecycle before it gets updated. Strapi is almost useless for the feature my company needs (viewing change log and version control of data updates) without this feature since 90% of our data is component based. Would anyone know an alternative solution to how I could get pre-updated component data before it updates? And then compare the old vs. updated component data?
Nitara
Sem Limi: I saw an idea to fetch the data from old record, but after I tried that, I get the same data for components - since components are saved before lifecycle events are even fired (as far as I understand it).
Boegie19
Nitara: If you use a before hook it should be fired before the components are saved if that is not the cease you could add a middleware that fires before you even call the lifecycle
Nitara
Boegie19: Yes, I am using beforeCreate/beforeUpdate and data there contains just IDs of records in components - but I can fetch that with a bit of additional code. The issue is that fetched old record and data sent to lifecycle method is the same (for components). I will check out this middleware method - did not use those until now in Strapi, but sounds like a feasible idea, with probably some other gotchas, but well, that is programming :D Thank you!
Fahid Mohammad
Any luck guys? this is a much needed solution.
Ebrahim Alkandary
yes it would be great, I've been stuck to find a solution for this matter
Sven Bretschneider
Or at least make component data visible in before... lifecycle hooks of content types
James Ricketts
Agreed! This would be extremely useful.