Home>Support>Custom Field I created always returns an error in the backend

Custom Field I created always returns an error in the backend

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

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 8 years, 10 months ago Enrico Ripalti

    … 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

  2. 8 years, 10 months ago Enrico Ripalti

    … really no one can help? :-(

  3. 8 years, 10 months ago Enrico Ripalti

    … 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.

  4. 8 years, 23 days ago Siege36

    Thanks for posting this. That was exactly my problem.

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More