• Resolved Begin

    (@bentalgad)


    Hi,

    I have a front end form set to load values (source) from {form:edited_post}. after setting it in my code like this:

    add_filter("acfe/form/load/form=add-activity", "get_posd_id_to_form", 10, 2);
    add_filter("acfe/form/load/form=edit-activity", "get_posd_id_to_form", 10, 2);
    function get_posd_id_to_form($form, $post_id)
    {
        // retrieve url parameter
        $edited_post = (int) $_GET["edp"];
    
        // Add Current User ID
        $form["edited_post"] = $edited_post;
    
        // Return
        return $form;
    }

    It was working fine until a few days ago (i don’t know if it has to do with the latest update)…

    I also checked the id is passing through by putting {form:edited_post} in the forms render html.

    Also tried this code:

    add_filter('acfe/form/load_post_id/form=edit-activity', 'my_post_load_id', 10, 3);
    function my_post_load_id($post_id, $form, $action){
        
        // retrieve url parameter
        $post_id = (int) $_GET["edp"];
        
        // return normally
        return $post_id;
        
    }

    I also just made sure the form is working to load the values if it is used in the post it self and the source is set to “current post” and it does.

    This is my form’s json:

    [
        {
            "name": "edit-activity",
            "title": "Edit Activity",
            "active": true,
            "field_groups": [
                "group_64415db154309",
                "group_64415e4c1e42b",
                "group_64411665904ad",
                "group_64cabec1b0eeb",
                "group_64dbef40c2d0c",
                "group_656772251e8ce"
            ],
            "settings": {
                "location": false,
                "honeypot": true,
                "kses": true,
                "uploader": "basic"
            },
            "attributes": {
                "form": {
                    "element": "form",
                    "class": "acf-form",
                    "id": ""
                },
                "fields": {
                    "element": "div",
                    "wrapper_class": "",
                    "class": "",
                    "label": "top",
                    "instruction": "label"
                },
                "submit": {
                    "value": "Submit",
                    "button": "<!--<input type=\"submit\" class=\"acf-button button button-primary button-large\" value=\"%s\" \/>-->",
                    "spinner": "<!--<span class=\"acf-spinner loader\"><\/span>-->"
                }
            },
            "validation": {
                "hide_error": true,
                "hide_revalidation": true,
                "hide_unload": true,
                "errors_position": "below",
                "errors_class": ""
            },
            "success": {
                "hide_form": false,
                "message": "Post updated",
                "wrapper": "<div id=\"message\" class=\"updated\">%s<\/div>"
            },
            "actions": [
                {
                    "action": "post",
                    "name": "update-activity-post",
                    "type": "update_post",
                    "save": {
                        "target": "{form:edited_post}",
                        "post_type": "activity",
                        "post_status": "",
                        "post_title": "{field:field_64492eb88e81c}",
                        "post_name": "",
                        "post_content": "{field:field_64dbef414ac94}",
                        "post_excerpt": "",
                        "post_author": "",
                        "post_parent": "",
                        "post_date": "",
                        "post_thumbnail": "",
                        "post_terms": "",
                        "append_terms": "",
                        "acf_fields": [
                            "field_64492eb88e81c",
                            "field_6605c07412d16",
                            "field_64415db155f3d",
                            "field_64415db155f40",
                            "field_645a4a162004e",
                            "field_648a0ad90f268",
                            "field_6449307c01171",
                            "field_64415db155f46",
                            "field_646ba4eafa243",
                            "field_648b2024f159b",
                            "field_64410da1bb181",
                            "field_64410a12a1f65",
                            "field_6441188f2d60b",
                            "field_645bb26a1fb4e",
                            "field_64415498ee5cf",
                            "field_645bb2bb1fb4f",
                            "field_645bb3231fb51",
                            "field_645bb3371fb52",
                            "field_644154752d60c",
                            "field_645bb3581fb53",
                            "field_6441550dee5d4",
                            "field_6489f726b1a80",
                            "field_645bbcfbdfbf1",
                            "field_645bbb8a054dd",
                            "field_645bbb9b054de",
                            "field_645bbc14054df",
                            "field_655e3b44e70db",
                            "field_64dbef414ac94",
                            "field_656772254bed2"
                        ]
                    },
                    "load": {
                        "source": "{form:edited_post}",
                        "post_type": "",
                        "post_status": "",
                        "post_title": "field_64492eb88e81c",
                        "post_name": "",
                        "post_content": "",
                        "post_excerpt": "",
                        "post_author": "",
                        "post_parent": "",
                        "post_date": "",
                        "post_thumbnail": "",
                        "post_terms": "",
                        "acf_fields": [
                            "field_64492eb88e81c",
                            "field_6605c07412d16",
                            "field_64415db155f3d",
                            "field_64415db155f40",
                            "field_645a4a162004e",
                            "field_648a0ad90f268",
                            "field_6449307c01171",
                            "field_64415db155f46",
                            "field_646ba4eafa243",
                            "field_648b2024f159b",
                            "field_64410da1bb181",
                            "field_64410a12a1f65",
                            "field_6441188f2d60b",
                            "field_645bb26a1fb4e",
                            "field_64415498ee5cf",
                            "field_645bb2bb1fb4f",
                            "field_644154d1ee5d1",
                            "field_644154e0ee5d2",
                            "field_644154f3ee5d3",
                            "field_645bb3231fb51",
                            "field_645bb3371fb52",
                            "field_644154752d60c",
                            "field_645bb3581fb53",
                            "field_6441550dee5d4",
                            "field_6489f726b1a80",
                            "field_645bbcfbdfbf1",
                            "field_645bbb8a054dd",
                            "field_645bbb9b054de",
                            "field_645bbc14054df",
                            "field_655e3b44e70db",
                            "field_655e3b9ee70dd",
                            "field_64dbef414ac94",
                            "field_652567efb96db",
                            "field_656772254bed2"
                        ]
                    }
                },
                {
                    "action": "email",
                    "name": "lotan-check-discount-update",
                    "email": {
                        "from": "Baypass <[email protected]>",
                        "to": "[email protected]",
                        "reply_to": "",
                        "cc": "",
                        "bcc": "",
                        "subject": "New discount approval needed",
                        "content": "Please check new discount:\r\n\r\n{action:post:admin_url}",
                        "html": false
                    },
                    "attachments": []
                },
                {
                    "action": "redirect",
                    "name": "",
                    "url": "https:\/\/kos.baypass.me\/partner"
                }
            ],
            "render": "<div class=\"stepFormContainer\">\r\n    {form:edited_post}\r\n  <div class=\"step\" id=\"step1\">\r\n    <h3>Promotion Details<\/h3>\r\n      <fieldset>\r\n      <field>{render:discount_name}<\/field>\r\n                              <div class=\"title_letters_count\">0 \/ 55<\/div>\r\n<field>{render:discount_conditions}<\/field>\r\n                    <div class=\"condition_letters_count\">0 \/ 50<\/div>\r\n\r\n      <field>{render:activity_description_optional}<\/field>\r\n          <div class=\"desc_letters_count\">0 \/ 500<\/div>\r\n      <field>{render:activity_price_starting_at}<\/field>\r\n                    <field>{render:discount_or_gift}<\/field>\r\n\r\n      <field>{render:activity_discount_amount}<\/field>\r\n          <div class=\"form_row\">\r\n      <field columns=\"2\">{render:activity_age_limit}<\/field>\r\n      <field columns=\"2\">{render:activity_duration}<\/field>\r\n          <\/div>\r\n  \r\n      <field>{render:activity_booking_required}<\/field>\r\n      <field>{render:booking_url}<\/field>\r\n          <\/fieldset>\r\n  <\/div>\r\n    \r\n      <div class=\"step\" id=\"step2\">\r\n    <h3>Business Details<\/h3>\r\n          <fieldset>\r\n    <field>{render:business_email}<\/field>\r\n     <field>{render:business_phone}<\/field>\r\n          <field>{render:business_website}<\/field>\r\n                            <field>{render:parent_beach}<\/field>\r\n\r\n          <field>{render:business_google_map_location}<\/field>\r\n              <\/fieldset>\r\n\r\n  <\/div>\r\n  <div class=\"step\" id=\"step3\">\r\n    <h3>Promotion Images<\/h3>\r\n      <fieldset>\r\n    <field>{render:medianlinks_youtube_link}<\/field>\r\n      <field>{render:medianlinks_gallery}<\/field>\r\n      <\/fieldset>\r\n      <field>{render:ask_for_real_client_agree}<\/field>\r\n  <\/div>\r\n<\/div>\r\n\r\n<div class=\"stepFormButtons\">\r\n  <div class=\"remove_discount\"><img src=\"https:\/\/kos.baypass.me\/wp-content\/uploads\/2023\/08\/np_trash_6026493_000000.png\" \/><\/div>\r\n  <button type=\"button\" class=\"back\">Back<\/button>\r\n  <button type=\"button\" class=\"next\">Next<\/button>\r\n    <div class=\"submit_wrap\">\r\n  <input type=\"submit\" class=\"acf-button button button-primary button-large\" style=\"display: none;\" value=\"Update\" \/>\r\n        <div class=\"submit_loader\">\r\n        <img src=\"https:\/\/kos.baypass.me\/wp-content\/uploads\/2023\/08\/Loader.gif\" \/><\/div>\r\n    <\/div>\r\n<\/div>"
        }
    ]

    This is a video showing the form settings and so:

    https://share.cleanshot.com/J1B7bk1P

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Begin

    (@bentalgad)

    Downgrading to 0.9 solved it. seem to be a problem in the latest version (0.9.0.2)?

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    Your report is pretty complete, thanks! The {form:edited_post} looks correctly configured. Few questions:

    • Does the Post 10173 has actual ACF Fields with values in the WP Admin?
    • By any chance, do you have another field called discount_name in another field group other than “Activity”?

    ACF can be capricious if there are multiple fields with the same “name” in different Field Groups. It will just get the first one it finds in all your field groups, which might not be the one that is configured to be filled.

    Try to use {render:field_64492eb88e81c} instead of {render:discount_name} in the Render, see if the field get filled.

    Regards.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Okay I managed to reproduce the issue.

    If fact, you should use the new hook acfe/form/load_form with a lower priority than 10. This is an unintended side effect. I’m adding a fix for the next patch.

    Here is the correct hook code:

    add_filter("acfe/form/load_form/form=add-activity", "get_posd_id_to_form", 9);
    add_filter("acfe/form/load_form/form=edit-activity", "get_posd_id_to_form", 9);
    function get_posd_id_to_form($form)
    {
        // retrieve url parameter
        $edited_post = (int) $_GET["edp"];
    
        // Add Current User ID
        $form["edited_post"] = $edited_post;
    
        // Return
        return $form;
    }

    The note I explained above regarding other fields using the same name in other field groups, still remains. I’ll enhance the logic to search field by name within the field groups defined in the form first. If no field was not found, then search across all field groups in ACF.

    The next version will also work with the old hook you’re using right now, with your current priority.

    I’ll let you know once the patch is up.

    Sorry for the inconvenience.

    Regards.

    Thread Starter Begin

    (@bentalgad)

    Hi,
    Thanks.

    yes, the post has acf fields with values, and i don’t have two fields with the same name, but it’s nice to make sure it works in cases like that also, great!

    I guess i will stay with my code now and with the 0.9 version for now until fixed. will be glad if you let me know when it’s out.

    thanks you very much!

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Roger that. I’ll do that!

    Regards.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Just a heads up to let you know that the latest 0.9.0.3 version fixed this issue.

    You can now use the ook

    add_filter("acfe/form/load_form/form=add-activity", "get_posd_id_to_form");

    or the old hook

    add_filter("acfe/form/load/form=add-activity", "get_posd_id_to_form", 10, 2);

    or the load_post_id hook

    add_filter('acfe/form/load_post_id/form=edit-activity', 'my_post_load_id', 10, 3);

    They will all work as expected (no more need to be at priority lower than 9).

    Thanks and sorry for the inconvenience.

    Have a nice day!

    Regards.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Field values not loading’ is closed to new replies.