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 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users