MjHead / jet-engine-extend-form-action

jet-engine-extend-form-action
5 stars 0 forks source link

Config example

 add_filter( 'jet-engine-extend-form-actions/config', function() {
    return array(
        123 => array(
            '_form_field_1' => array(
                'prop' => 'post_meta',
                'key'  => '_meta_key',
            ),
            '_form_field_2' => array(
                'prop' => 'post_terms',
                'tax'  => 'taxonomy_slug',
                'by'   => 'name',
            ),
            '_form_field_3' => array(
                'prop'   => 'post_data',
                'key'    => 'post_title',
                'suffix' => ' -',
            ),
            '_form_field_4' => array(
                'prop'   => 'post_data',
                'key'    => 'post_title',
                'prefix' => ' ',
            ),
        ),
    );
 } );

Where:

How to use

Combine post title from multiple form fields example

Meta fields only:

add_filter( 'jet-engine-extend-form-actions/config', function() {
    return array(
        537 => array(
            '_form_field_1' => array(
                'prop'   => 'post_data',
                'key'    => 'post_title',
                'prefix' => '#',
                'suffix' => ':',
            ),
            '_form_field_2' => array(
                'prop'   => 'post_data',
                'key'    => 'post_title',
                'prefix' => ' ',
                'suffix' => '!',
            ),
        ),
    );
} );

Meta fields combined with taxonomy terms:

add_filter( 'jet-engine-extend-form-actions/config', function() {
    return array(
        537 => array(
            '_test_field_2' => array(
                'prop' => 'post_data',
                'key'  => 'post_title',
            ),
            '_test_field' => array(
                'prop'   => 'post_data',
                'key'    => 'post_title',
                'tax'    => 'category',
                'prefix' => ', ',
            ),
        ),
    );
} );

Multiple props for the same form field example

add_filter( 'jet-engine-extend-form-actions/config', function() {
    return array(
        39 => array(
            'inserted_post_id' => array(
                'props' => array(
                    array(
                        'prop'   => 'post_data',
                        'key'    => 'post_title',
                        'prefix' => '#',
                    ),
                    array(
                        'prop'   => 'post_data',
                        'key'    => 'post_name',
                    ),
                ),
            ),
        ),
    );
} );