Changing Fluent Form global vars

tdrayson

A user in the Fluent Form Facebook group, was looking for a way to translate the multi-select dropdown max options text.

There is a filter inside the plugin that allows us to update this.

All available global vars

Below is a list of all available variables that can be updated.

PHP

        $vars = [
    "ajaxUrl" => admin_url("admin-ajax.php"),
    "forms" => [],
    "step_text" => $stepText,
    "is_rtl" => is_rtl(),
    "date_i18n" => $this->getDatei18n(),
    "pro_version" => defined("FLUENTFORMPRO_VERSION") ? FLUENTFORMPRO_VERSION : false,
    "fluentform_version" => FLUENTFORM_VERSION,
    "force_init" => false,
    "stepAnimationDuration" => 350,
    "upload_completed_txt" => __("100% Completed", "fluentform"),
    "upload_start_txt" => __("0% Completed", "fluentform"),
    "uploading_txt" => __("Uploading", "fluentform"),
    "choice_js_vars" => [
        "noResultsText" => __("No results found", "fluentform"),
        "loadingText" => __("Loading...", "fluentform"),
        "noChoicesText" => __("No choices to choose from", "fluentform"),
        "itemSelectText" => __("Press to select", "fluentform"),
        "maxItemText" => __( "Only %%maxItemCount%% options can be added", "fluentform"),
    ],
    "input_mask_vars" => [
        "clearIfNotMatch" => false,
    ],
];
      
Copy
FluentForm\App\Modules\Component - line 548

Example

Below is an example of updating one of the variables.

PHP

        add_filter("fluentform_global_form_vars", "tct_global_form_vars", 10, 1);
function tct_global_form_vars($vars){
    $vars["choice_js_vars"]["maxItemText"] = "You can select a max of %%maxItemCount%% items";
    return $vars;
}
      
Copy

👋🏻 Weekly Tutorial Digest

I send out a weekly newsletter with links to new tutorials written in the last week, you can subscribe below.

Newsletter

🔒I won't send you spam, I promise