toolbox/helpers/sc_attr/type={fieldtype}

Estimated reading: 1 minute

This filter sets the default parameters for a fieldtype. This filter is required when adding a new fieldtype to Toolbox.

NOTE: Any attributes that are not defined using this filter will be ignored.

Parameters

  • $attr (array) key=>value pairs

Usage

It is advised to add the default shortcode attributes callback first:

<?php

add_filter( 'toolbox/helpers/sc_attr/type=new_fieldtype' , 'toolbox::return_shortcode_attr_default',10 ,1 );

This will set a baseline for the settings that interact with the various parts of Toolbox, for instance the fetching of data from other posts, applying the twig template and getting the fieldname.

After this you are free to add your own. Alternatively you can skip adding the callback mentioned above and just add your own set of defaults.

<?php

add_filter( 'toolbox/helpers/sc_attr/type=new_fieldtype', 'my_own_attr_defaults' , 10 , 1 );

function my_own_attr_defaults ( $attr = array() ) {
    $new_attr = array( 'field' => '',
				'format'    => null,
				'allowempty'	=> 'false',
				'postid'    => 0,
				'nodeid'    => null,            // beaver builder node id
				'twigtemplate'	=> false,
				);

    return array_merge ( $attr , $new_attr );
}
Share this Doc

toolbox/helpers/sc_attr/type={fieldtype}

Or copy link

CONTENTS