Support

Account

Home Forums Front-end Issues Detecting unsaved data

Helping

Detecting unsaved data

  • Hi.. I have a page with several acf forms on it each with its own submit button. They all work correctly and independently. The user is able to edit the data in the various fields and submit the data as they go, forcing an update of the post that they are editing. The behavior that I am now looking for is to indicate to the user that there is modified data on the form that needs to be submitted.

    One issue is how to detect that there is unsaved data on a form and the other is how to indicate that to the user. So far my searches have not given me any leads as to how I might accomplish this, if indeed it is doable. Any help appreciated.

  • This is the code for one of my forms. Each form has its own shortcode

    add_shortcode( 'ibsc_scp_stage2', 'scp_stage2' );
    function scp_stage2() {
    
      //retrieve scp-id from URL
      if ( isset( $_GET['scp-id'] ) ) {
        $scp_id = sanitize_text_field( $_GET['scp-id'] );
      } //end if
    
      //assemble $form_config array  
      $form_config = array(
        'post_id' => $scp_id,
        'new_post' => false,
        'post_title' => false,  
        'form' => true,
        'field_groups' => array(),  //blank     
        'fields' => array(
           'field_683c1e59136a4', //scp_sch_nam - tx
           'field_683c1ed529a74', //scp_pho_typ - tx  
        ), //end of fields array
        'submit_value'  => __('Update Taxonomies'),  
      );  //end of form_config array
      
      //process acf form
      ob_start();
      acf_form($form_config);
      $ob = ob_get_clean();
     return $ob; 
    
    } //end function
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.