I had a question about the Types API in PHP. I'm aware of types_render_field() and similar functions (https://toolset.com/documentation/customizing-sites-using-php/functions/), but I was wondering if there were any PHP functions for programmatically retrieving information about Toolset fields. For example, given a field slug, can one obtain the field type? Is that possible, and if so, how?
You can call the above shortcode as given under. For exmaple, you have created a custom field with slug "my-book" and to get its field type, you can call the following shortcode:
[toolset_field_type field="my-book"]
It should return you the custom field type.
If you want to get specific field within the specific custom field group then, for instance, if the custom field group slug is "my-custom-field-group" and the custom field added to this group and its slug is "my-custom-field" then you can use the following code:
I'm still running into the same fatal PHP error ("Uncaught Error: Class 'OTGS\Toolset\Common\PublicAPI\ElementDomain' not found"). I suspect it's because the shortcode is executing before the Toolset plugins have loaded. I tried changing loading my shortcodes on the "plugins_loaded" hook, but the PHP error persisted. Any advice?
I sort of gave up using the PHP API and resorted to retrieving the "wpcf-fields" option in wp_options. The array contains the custom fields and their field types (as well as a bunch of other info). Good enough for me!