Support

Account

Home Forums Front-end Issues get all multi-select values

Helping

get all multi-select values

  • Hey guys,

    I’ve made it possible to gather and save all the values of the act fields by using the following code: (might not work directly in other code)

    $.find('input, textarea, select').each(function () {
        var name = jQuery(this).attr("name");
        if (this.parentNode.nodeName === "LI") {
          if (!Array.isArray(post_data[name])) {
            post_data[name] = [];
          }
          post_data[name].push(jQuery(this).val());
        } else if (!post_data[name]) {
          post_data[name] = jQuery(this).val();
        }
        if (jQuery(this).attr("checked")) {
          post_data[name] = "checked";
        }
        if (this.selectedIndex>0 && this.options && this.options.length > 0) {
          console.log(this.selectedIndex);
          post_data[name] = this.options[this.selectedIndex].value;
        }
      });

    This code return’s the following values in version 5.3.2.2:

    _acf_form: "eyJpZCI6ImFjZi1mb3JtIiwicG9zdF9pZCI6IjI0IiwibmV3X3Bvc3QiOmZhbHNlLCJmaWVsZF9ncm91cHMiOls2LDhdLCJmaWVsZHMiOmZhbHNlLCJwb3N0X3RpdGxlIjp0cnVlLCJwb3N0X2NvbnRlbnQiOnRydWUsImZvcm0iOmZhbHNlLCJmb3JtX2F0dHJpYnV0ZXMiOnsiaWQiOiJwb3N0IiwiY2xhc3MiOiIgYWNmLWZvcm0iLCJhY3Rpb24iOiIiLCJtZXRob2QiOiJwb3N0In0sInJldHVybiI6Imh0dHA6XC9cL2xvY2FsaG9zdFwvb2RpblwvYm9va1wvaG9pLTJcLz91cGRhdGVkPXRydWUiLCJodG1sX2JlZm9yZV9maWVsZHMiOiIiLCJodG1sX2FmdGVyX2ZpZWxkcyI6IiIsInN1Ym1pdF92YWx1ZSI6IkJpandlcmtlbiIsInVwZGF0ZWRfbWVzc2FnZSI6IkJlcmljaHQgYmlqZ2V3ZXJrdCIsImxhYmVsX3BsYWNlbWVudCI6InRvcCIsImluc3RydWN0aW9uX3BsYWNlbWVudCI6ImxhYmVsIiwiZmllbGRfZWwiOiJkaXYiLCJ1cGxvYWRlciI6IndwIiwiaHRtbF9maWVsZF9vcGVuIjoiPGRpdj4iLCJodG1sX2ZpZWxkX2Nsb3NlIjoiPFwvZGl2PiJ9"
    _acfchanged: "0"
    _acfnonce: "7135cdc8a7"
    acf[_post_content]: ""
    acf[_post_title]: "hoi"
    acf[field_5630c8fa19205]: ""
    acf[field_562106be02b97]: "26||30"
    acf[field_562106be02b97][]: ["26", "30"] (2)
    action: "save_my_data"
    status: "publish"
    undefined: [""]

    In version 5.3.3.2 it return’s this code:

    _acf_form: "eyJpZCI6ImFjZi1mb3JtIiwicG9zdF9pZCI6IjI0IiwibmV3X3Bvc3QiOmZhbHNlLCJmaWVsZF9ncm91cHMiOls2LDhdLCJmaWVsZHMiOmZhbHNlLCJwb3N0X3RpdGxlIjp0cnVlLCJwb3N0X2NvbnRlbnQiOnRydWUsImZvcm0iOmZhbHNlLCJmb3JtX2F0dHJpYnV0ZXMiOnsiaWQiOiJwb3N0IiwiY2xhc3MiOiIgYWNmLWZvcm0iLCJhY3Rpb24iOiIiLCJtZXRob2QiOiJwb3N0In0sInJldHVybiI6Imh0dHA6XC9cL2xvY2FsaG9zdFwvb2RpblwvYm9va1wvaG9pLTJcLz91cGRhdGVkPXRydWUiLCJodG1sX2JlZm9yZV9maWVsZHMiOiIiLCJodG1sX2FmdGVyX2ZpZWxkcyI6IiIsInN1Ym1pdF92YWx1ZSI6IkJpandlcmtlbiIsInVwZGF0ZWRfbWVzc2FnZSI6IkJlcmljaHQgYmlqZ2V3ZXJrdCIsImxhYmVsX3BsYWNlbWVudCI6InRvcCIsImluc3RydWN0aW9uX3BsYWNlbWVudCI6ImxhYmVsIiwiZmllbGRfZWwiOiJkaXYiLCJ1cGxvYWRlciI6IndwIiwiaHRtbF9maWVsZF9vcGVuIjoiPGRpdj4iLCJodG1sX2ZpZWxkX2Nsb3NlIjoiPFwvZGl2PiJ9"
    _acfchanged: "1"
    _acfnonce: "7135cdc8a7"
    acf[_post_content]: ""
    acf[_post_title]: "hoi"
    acf[field_5630c8fa19205]: ""
    acf[field_562106be02b97]: "26||30"
    acf[field_562106be02b97][]: ["26", "30"] (2)
    action: "save_my_data"
    status: "publish"
    undefined: [""]

    Since the update to 5.3.3.2 somehow this code doesn’t work anymore.
    The action ‘save_my_data’ refers to acf_form_head.

    Does anyone have any idea how this is possible and what I have to change?

    If you need more info please ask, I’m totally stuck on this!

    Thanks a lot!

    Tim

  • Hi Tim,

    Looks like the same result after updating to 5.3.3.2? Or am I missing something..?

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘get all multi-select values’ is closed to new replies.