The Alias Settings Form

Estimated reading: 2 minutes

In order to add settings for your Alias Modules, you can register a Settings Form. The settings will appear as a popup form and will apply after the popup is saved and closed.

Having the settings appear as a popup and not updating live is slightly less convenient. On the other hand, it is does allow us to have different settings for different instances of the same (alias) module. Another advantage is that Alias Modules don’t need to exist after having been added to the layout, whereas regular modules need to remain active once they are being used.

<?php

/**
 * Callback used to return the users of this WP site
 * @return array
 */
function starter_return_users() {

    $select_options = array();

    // get the list of users
    $users = get_users();

    foreach ( $users as $user ) {
        $select_options[ $user->ID ] = $user->user_nicename;
    }

    return $select_options;
}

\FLBuilder::register_settings_form('toolbox_starter_user_info_settings', array(
        'title' => __('Settings', 'textdomain'),
        'tabs'  => array(
            'general'      => array(
                'title'         => __('General', 'textdomain'),
                'sections'      => array(
                    'general'       => array(
                        'title'         => 'General',
                        'fields'        => array(
                            'starter_user'     => array(
                                'type'          => 'select',
                                'label'         => __( 'Display User', 'textdomain' ),
                                'default'       => get_current_user_id(),
                                'options'       => starter_return_users(),
                                'multi-select'    => false,
                            ),
                        )
                    ),
                )
            )
        )
    )
);
Expand

The settings form is added in the same way as usual, you can follow Beaver Builder’s knowledge base article for reference.

Please note that it does come with a few limitations. One of those is that you can’t nest form fields.

Location of settings

If you’ve added a settings form to your Alias Module, the Settings field and ‘Edit Settings’-link will be made visible for it.

toolbox_docs-plugin_dev2

Clicking the “Edit Settings” link will bring up the Settings Form and you will be able so change them and save.

Share this Doc

The Alias Settings Form

Or copy link

CONTENTS