lundi 24 août 2020

Gravity Forms Alphabetic Order Dropdown and Checkboxes field after WPML translation

I am using Gravity Forms with WPML. I have some Dropdown and Checkboxes Fields. In English Dropdown and Checkboxes are in alphabetic order. All ok. But in my translation form, the system keeps the English order not the translation order. I would like to have a snippet that force Dropdown and Checkboxes fields to be in alphabetic order, no matter the language. I try to use the code below in my function.php without success. If someone could help it will make my day.

    add_filter("gform_pre_render_39", "sort_categories");
    function sort_categories($form){
    foreach($form["fields"] as &$field){
    if($field->id == 1)
        usort($field["choices"], "sort_numerically");
    }
    return $form;
    }
    function sort_numerically($a, $b){
    return floatval($a["text"]) > floatval($b["text"]);
    }

My ID form is 39 My ID Dropdown field is 1

Thank you for your help




Aucun commentaire:

Enregistrer un commentaire