Support

Account

Home Forums Backend Issues (wp-admin) Generating multiple forms on the same page (and saving them) Reply To: Generating multiple forms on the same page (and saving them)

  • I tried your code with a little bit changes and it’s working,
    I think you have missed 'field_groups' => array(YOUR_FIELD_GROUP_ID), in your acf_form() , Try adding the id of your field group to the acf_form()

    <?php
    function woocommerce_variation_options_acf_form($loop, $variation_data, $variation) {
      add_action('admin_head','acf_form_head',20);
      $variation_id = $variation->ID;
      
      ?>
      <tr><td colspan="2">
      <style>
      table.data_table td #poststuff { padding: 0; min-width: 1em;}
      table.data_table td .postbox { min-width: 1em;}
      table.data_table td div.acf_postbox div.field_type-true_false p.label { display: inline; }
      table.data_table td div.acf_postbox div.field_type-true_false ul {display: inline-block;}
      #variable_product_options .woocommerce_variation table td input[type='checkbox'] { min-width: 1em!important;}
      </style>
      
      <?php
      acf_form(array(
          'post_id' => $variation_id,
          'form' => false,
          'label_placement' => 'top',
          'instruction_placement' => 'label',
    	  'field_groups' => array(28),
          'return' => add_query_arg( array( 'post_id' => $post_id, 'updated' => 'true'), get_permalink() ),
          ));
     // var_dump(  $variation_id  );
          ?>
          <script type="text/javascript">
    (function($) {
      // setup fields
      acf.do_action('append', $('#popup-id'));
    })(jQuery); 
    </script>
    </td></tr>
    <?php
    
    }
    add_action('admin_head','acf_form_head',20);
    add_action('woocommerce_product_after_variable_attributes','woocommerce_variation_options_acf_form',99);
    
    /**
    In WooCommerce : includes/admin/meta-boxes/views/html-variation-admin.php
    */
     do_action( 'woocommerce_product_after_variable_attributes', $loop, $variation_data, $variation ); ?>

    try this and use your own field group id instead of ’28’ in 'field_groups' => array(28)