This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Custom Field I created always returns an error in the backend

Resolved 4 replies pluginplugin-page-builder
10 years ago · Last reply by Siege36 9 years ago

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.

Need fast email support? Get SiteOrigin Premium

Replies

4
  1. Enrico Ripalti 10 years, 3 months ago

    … 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. Enrico Ripalti 10 years, 3 months ago

    … really no one can help? :-(

  3. Enrico Ripalti 10 years, 3 months ago

    … 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. Siege36 9 years, 5 months ago

    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.

Have a different question or issue?

Start New Thread