Hi @wootimes
For something like that, you need to create custom code that will generate the PHP code. Please check how ACF does it in “wp-content/plugins/advanced-custom-fields-pro/admin/settings-tools.php”. After that, you can hook it to WordPress save_post hook.
I hope this makes sense 🙂