Hey there!
I am having problems creating a custom field for a widget. I am basically following what is found here https://siteorigin.com/docs/widgets-bundle/form-building/adding-custom-fields/.
I think I have followed every step, also including the custom class I made for the example via the code
function my_custom_fields_class_prefixes( $class_prefixes ) {
$class_prefixes[] = 'My_Custom_Field_';
return $class_prefixes;
}
add_filter( 'siteorigin_widgets_field_class_prefixes', 'my_custom_fields_class_prefixes' );
function my_custom_fields_class_paths( $class_paths ) {
$class_paths[] = get_template_directory() . '/includes/page-builder/fields/';
return $class_paths;
}
add_filter( 'siteorigin_widgets_field_class_paths', 'my_custom_fields_class_paths' );
Still, it returns this error when the widget is opened for editing in the page builder: “The class ‘SiteOrigin_Widget_Field_Better_Text’ could not be found. Please make sure you specified the correct field type and that the class exists.”
Any ideas?
Thanks!
Enrico
… BTW: I have called the custom field from a widget I created like this
function __construct() { parent::__construct( 'cm-post-carousel', __('Magic Carousel', 'commly-admin'), array( 'description' => __('Display your posts or product as a carousel.', 'commly-admin'), 'help' => 'https://siteorigin.com/widgets-bundle/post-carousel-widget/', 'icon' => 'dashicons dashicons-images-alt' ), array( ), array( 'title' => array( 'type' => 'text', 'label' => __('Title', 'so-widgets-bundle'), ), 'posts' => array( 'type' => 'posts', 'label' => __('Posts query', 'so-widgets-bundle'), ), 'text' => array( 'type' => 'better-text', 'my_property' => 'This is my custom property value', 'label' => __( 'A better text field.', 'my-custom-field-test-widget-text-domain' ), 'description' => __( 'A description for my custom text field.' ), 'default' => 'Some better text.' ), ), plugin_dir_path(__FILE__).'../' );As you can see, I have a filed named text with type => better-text
… really no one can help? :-(
… it seems not even Site Origin staff could help on this. Anyway I figured out later what the problem was, so I’ll post it here just in case someone else needs a solution to this.
When you add a new custom field, make sure to name the class file as “.class.php” or the thing will not recognize it, and you will be prompted with the error I got.
Thanks for posting this. That was exactly my problem.