Support

Account

Home Forums Add-ons Repeater Field acf_form front end isn\'t loading saved data on redirect?

Solved

acf_form front end isn\'t loading saved data on redirect?

  • Hello,

    I’m integrating an acf_form into an existing form and everything seems to be working upon saving the data .. my $_POST[‘acf’] is saving properly

    array(1) {
      ["field_566fa921a660d"]=>
      array(2) {
        [0]=>
        array(2) {
          ["field_566fa98aa660e"]=>
          string(12) "adwrerwerwer"
          ["field_566fa9b1a660f"]=>
          string(4) "1793"
        }
        ["5671200325c14"]=>
        array(2) {
          ["field_566fa98aa660e"]=>
          string(11) "ryandennler"
          ["field_566fa9b1a660f"]=>
          string(4) "1789"
        }
      }
    }

    and my data is being saved into the database under the option name in wp_options:

    a:2:{i:0;a:2:{s:19:"field_566fa98aa660e";s:12:"adwrerwerwer";s:19:"field_566fa9b1a660f";s:4:"1793";}s:13:"5671200325c14";a:2:{s:19:"field_566fa98aa660e";s:11:"ryandennler";s:19:"field_566fa9b1a660f";s:4:"1789";}}

    However when it refreshes on the front end after I hit submit, it doesn’t load those saved values.

    This is the form code I’m using to output:

    <?php acf_form(array(
    				'id' => get_the_ID(),
    				'form'  => false
    				)); ?>

    Am I doing this wrong? My goal is to allow people to utilize a repeater field to add multiple lawyers in their law firm to their lawyer listing page. The form I’m using updates all of their post data already and I’m just integrating acf_form into that to apply this one bit of functionality.

    The data saves perfectly fine, the problem seems to be that when it loads acf_form , it’s not applying those saved values to the post I’m trying to update it for and it’s not loading those saved fields into the form so they can modify them in the future. I may be having this all wrong though on how it exactly works considering it’s saving as a wp_options value without a context to the post at all. I mean I thought it would save these values into wp_postmeta with a post context value but it’s just saving it as a static wp_options value.

    Edit: I will add that it seems to save AND load properly on refreshing when updating/publishing the post itself on the backend , it just doesn’t seem to load at all on the front end. I’m thinking I’m just calling acf_form incorrectly and it’s not linking to the post to load the correct values.

    Thanks guys

  • Actually, the acf_form seems to load the values properly only if I’ve saved those values from the backend. It seems the issue is that it simply just doesn’t save to the wp_postmeta table for that post properly so nothing is actually saved , although the data is saved to wp_options instead (confused about this in general) from looking in my database tables and also records the $_POST data to JSON properly upon updating so the culprit seems to lie in the functionality of actually binding the data to the wp_postmeta table.

    Anybody know the hooks utilized in this?

    Thanks

  • I got it figured out , it was actually a theme issue and the way the theme was handling front end submissions. I was able to hook into a custom action hook given by the theme and it worked properly by just hooking acf_save_form(get_the_ID()) into it.

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

The topic ‘acf_form front end isn\'t loading saved data on redirect?’ is closed to new replies.