Important: the export functionality changed in Caldera Forms 1.3.1. In previous versions export as json was the only option.
Caldera Forms provides two ways to export forms. The simplest way is to export it as a JSON file. This method is best for backups and moving form configurations between environments. In addition, you can export your form to a file that can be added to a plugin. This is a more advanced option for developers.
Exporting A Form
In the main Caldera Forms admin page, each form is listed with various options underneath it. This includes an “export” link. When you click this link, you will see a new modal. The default option is “Backup/ Importable (json)”. This is the option that you will use most of the time.
Simply click the “Export Form” button to download your form. This file can be used as a backup. It can also be used to import the form into another site or the same site, using the “Import” button at the top of the main Caldera Forms admin page.
Using export files is an excellent way to create backups and perform simple migrations or versioning form configuration.
Exporting As A PHP File
By default Caldera Forms configuration is stored in the database. While this works for most uses, it may be limiting for some developers. For example, form configuration can not be easily version controlled, and form configuration can not be built programatically. Yes, you can the “caldera_forms_get_forms” filter to modify the form configuration stored in the database, but for complex projects, with multiple developers, it is often necessary to define forms in the database.
The second option in the exporter is “PHP include File”. This option downloads PHP file with your form configuration and the necessary hooks to make the form work. The download file should either be included in a plugin file, made into a plugin (just add a valid plugin header) or can be place in your mu-plugins directory.
Once this file is included in your site, you can use the Caldera Forms shortcode or the method Caldera_Forms::render_form() to load the form, just like you would a form defined in the database. If entry tracking is enabled, entries will be viewable in the admin.
The PHP file export can optionally convert field IDs to their slugs. This is very useful, if you are addressing fields by ID in other part of your code.
Please note that while this file can be pasted into functions.php of your theme/ child theme that is not recommended. Doing so will cause your form to not work when you switch themes.
For more information on using forms defined in the file system, see this article.