• Resolved pierremaitre

    (@pierremaitre)


    Hi there,

    The form used to work fine with version 0.9.0.4.

    With 0.9.0.5, I get a fatal error when opening the form:

    Warning: foreach() argument must be of type array|object, string given in /wp-content/plugins/acf-extended/includes/modules/form/module-form-action.php on line 202
    Fatal error: Uncaught TypeError: array_values(): Argument #1 ($array) must be of type array, string given in /wp-content/plugins/acf-extended/includes/modules/form/module-form-action-post.php:215 Stack trace: #0 /wp-content/plugins/acf-extended/includes/modules/form/module-form-action-post.php(215): array_values() #1 /wp-includes/class-wp-hook.php(324): acfe_module_form_action_post->load_action() #2 /wp-includes/plugin.php(205): WP_Hook->apply_filters() #3 /wp-content/plugins/acf-extended/includes/modules/form/module-form-front.php(407): apply_filters() #4 /wp-includes/class-wp-hook.php(324): acfe_module_form_front->load_actions() #5 /wp-includes/plugin.php(205): WP_Hook->apply_filters() #6 /wp-content/plugins/acf-extended/includes/modules/form/module-form-front.php(75): apply_filters() #7 /wp-includes/class-wp-hook.php(324): acfe_module_form_front->load_form() #8 /wp-includes/plugin.php(205): WP_Hook->apply_filters() #9 /wp-content/plugins/acf-extended/includes/modules/form/module-form-front.php(439): apply_filters() #10 /wp-content/plugins/acf-extended/includes/modules/form/module-form-front.php(721): acfe_module_form_front->render_form() #11 /wp-content/plugins/oxygen/component-framework/components/classes/code-block.class.php(133) : eval()'d code(9): acfe_form() #12 /wp-content/plugins/oxygen/component-framework/components/classes/code-block.class.php(133): eval() #13 /wp-content/plugins/oxygen/component-framework/includes/templates.php(76): CT_Code_Block->add_shortcode() #14 /wp-content/plugins/oxygen/component-framework/components/classes/div-block.class.php(48): do_oxygen_elements() #15 /wp-content/plugins/oxygen/component-framework/includes/templates.php(76): CT_DIV_Block->add_shortcode() #16 /wp-content/plugins/oxygen/component-framework/components/classes/section.class.php(70): do_oxygen_elements() #17 /wp-content/plugins/oxygen/component-framework/includes/templates.php(76): CT_Section->add_shortcode() #18 /wp-content/plugins/oxygen/component-framework/components/classes/inner-content.class.php(62): do_oxygen_elements() #19 /wp-content/plugins/oxygen/component-framework/includes/templates.php(76): CT_Inner_Content->add_shortcode() #20 /wp-content/plugins/oxygen/component-framework/includes/templates.php(109): do_oxygen_elements() #21 /wp-content/plugins/oxygen/component-framework/includes/templates.php(183): ct_template_output() #22 /wp-includes/class-wp-hook.php(324): ct_templates_buffer_start() #23 /wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #24 /wp-includes/plugin.php(517): WP_Hook->do_action() #25 /wp-content/plugins/oxygen/component-framework/component-init.php(1272): do_action() #26 /wp-includes/class-wp-hook.php(324): oxy_print_cached_css() #27 /wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #28 /wp-includes/plugin.php(517): WP_Hook->do_action() #29 /wp-includes/general-template.php(3050): do_action() #30 /wp-content/plugins/oxygen/component-framework/oxygen-main-template.php(10): wp_head() #31 /wp-includes/template-loader.php(106): include('/home2/mapi7009…') #32 /wp-blog-header.php(19): require_once('/home2/mapi7009…') #33 /index.php(17): require('/home2/mapi7009…') #34 {main} thrown in /wp-content/plugins/acf-extended/includes/modules/form/module-form-action-post.php on line 215

    Thanks for your help.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    It looks like there is an issue with the selected ACF Fields in the “Load” tab of your Post Action.

    How do you register your form? Using the Form UI or with PHP code?

    If you’re using the Form UI, can you please export the Form in Json and share it? (either here, or using pastebin). If you’re using PHP code, can you please share your form PHP code?

    Thanks.

    Regards.

    Thread Starter pierremaitre

    (@pierremaitre)

    Hi Konrad,

    Thank you for your fast reply. Here is the form in Json.

    [
    {
    "name": "edition_reception",
    "title": "édition de réception",
    "active": true,
    "field_groups": [
    "group_5f66fbcb7ff51"
    ],
    "settings": {
    "location": 0,
    "honeypot": 1,
    "kses": 1,
    "uploader": "default"
    },
    "attributes": {
    "form": {
    "element": "form",
    "class": "acf-form",
    "id": ""
    },
    "fields": {
    "element": "div",
    "wrapper_class": "",
    "class": "",
    "label": "top",
    "instruction": "label"
    },
    "submit": {
    "value": "Enregistrer",
    "button": "<input type=\"submit\" class=\"acf-button button button-primary button-large\" value=\"%s\" \/>",
    "spinner": "<span class=\"acf-spinner\"><\/span>"
    }
    },
    "validation": {
    "hide_error": 0,
    "hide_revalidation": 0,
    "hide_unload": 0,
    "errors_position": "above",
    "errors_class": ""
    },
    "success": {
    "hide_form": 0,
    "scroll": false,
    "message": "Réception mise à jour",
    "wrapper": "<div id=\"message\" class=\"updated\">%s<\/div>"
    },
    "actions": [
    {
    "action": "post",
    "name": "ajout-reception",
    "type": "update_post",
    "save": {
    "target": "{request:receptions_id}",
    "post_type": "",
    "post_status": "",
    "post_title": "",
    "post_name": "",
    "post_content": "",
    "post_excerpt": false,
    "post_author": "",
    "post_parent": "",
    "post_date": "",
    "post_thumbnail": "",
    "post_terms": "",
    "append_terms": "",
    "acf_fields": [
    "field_5f66fc0cc4f71",
    "field_5f66fc20c4f72",
    "field_5f66fc5603a37",
    "field_5f66fc9b8db09",
    "field_5f674852a79d7"
    ]
    },
    "load": {
    "source": "{request:receptions_id}",
    "post_type": "",
    "post_status": "",
    "post_title": "",
    "post_name": "",
    "post_content": "",
    "post_excerpt": false,
    "post_author": "",
    "post_parent": "",
    "post_date": "",
    "post_thumbnail": "",
    "post_terms": "",
    "acf_fields": [
    "field_5f66fc0cc4f71",
    "field_5f66fc20c4f72",
    "field_5f66fc5603a37",
    "field_5f66fc9b8db09",
    "field_5f674852a79d7"
    ]
    }
    },
    {
    "action": "post",
    "name": "",
    "type": "update_post",
    "save": {
    "target": "{post}",
    "post_type": "",
    "post_status": "",
    "post_title": "",
    "post_name": "",
    "post_content": "",
    "post_excerpt": false,
    "post_author": "",
    "post_parent": "",
    "post_date": "",
    "post_thumbnail": "",
    "post_terms": "",
    "append_terms": "",
    "acf_fields": ""
    },
    "load": {
    "source": "{post}",
    "post_type": "",
    "post_status": "",
    "post_title": "",
    "post_name": "",
    "post_content": "",
    "post_excerpt": false,
    "post_author": "",
    "post_parent": "",
    "post_date": "",
    "post_thumbnail": "",
    "post_terms": "",
    "acf_fields": ""
    }
    }
    ],
    "render": ""
    }
    ]

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the details.

    The issue come from this line in your second Post Action, in the load array:

    "acf_fields": ""

    When it should be an empty array:

    "acf_fields": []

    I’m not quite sure how you ended up with an empty string "" instead of an empty array [] there. There is also the post_excerpt which is set to false, which is not a “normal” value.

    Since it was working before, did you make some custom operation on your form lately? You can try to re-save your form, it might fix the empty string back to empty array.

    As a side note, your second Post Action doesn’t do anything (it doesn’t load values, or doesn’t save any value). You can try to remove it, and re-add it too.

    Let me know if that fixed the issue.

    Thanks.

    Regards.

    Thread Starter pierremaitre

    (@pierremaitre)

    Bonjour Konrad,

    I removed the second post action. It doesn’t do anything indeed, I don’t know why I put it there. It works fine now, many thanks!

    Thread Starter pierremaitre

    (@pierremaitre)

    Another question: is it possible to go to another page after submitting the form?

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    I’m glad to hear it now works as expected.

    Did you do any custom operation lately on your form? I’m still curious to understand how you ended up with a malformed action.

    I’ll add some safe guard logic in the next patch in case this happen for some reason.

    Thanks.

    Regards.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Regarding your last question:

    Yes you can add a “Redirect Action” to redirect the user on form submission (See documentation). Just make sure to set it after your other actions, so it redirect the user after all actions are processed.

    Regards.

    Thread Starter pierremaitre

    (@pierremaitre)

    No action at all from me lately on the form. When I revert to version 0.9.0.4 of ACFE, it works fine and when I apply 0.9.0.5, fatal error.

    The second action has been there for a long time without any issue, although it was useless.

    Thanks again. Best regards.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Okay thanks. It might be a residue from an earlier upgrade. I’ll check it out.

    In all cases, saving the form would fix the issue.

    Thanks.

    Regards.

    Thread Starter pierremaitre

    (@pierremaitre)

    No, not only saving the form, but removing the second useless action.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Yes I know, but re-saving the form would also fix the issue, since it re-format the empty string (I just tested it). Removing the action was another fix in your case, since the action didn’t do anything.

    Regards.

    Thread Starter pierremaitre

    (@pierremaitre)

    Okay, Thanks a lot for all of this!

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    You’re welcome!

    Regards.

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.