#Converting rich-text to HTML before saving to database

10 messages · Page 1 of 1 (latest)

tired bane
#

I am trying to add a functionality to add a product description within payload cms as rich text. But I want to convert this to HTML before saving it to the data base. Can this be done?

lime gyro
#

yep! You can convert it to html in a beforeChange collection hook, and save that html into another field

tired bane
#

I am not surely how to go about this. Can you point me in the right direction or share an example @lime gyro

tired bane
#

Figured it out. It's working fine. Thank you!

slow coral
#

can you show us hou you did it? i'm interested on this..

tired bane
#

there is a section on generate html

#

use this in your before change hook

#

should work just fine