Support

Account

Home Forums ACF PRO acf_form() for specific flexible content rows

Unread

acf_form() for specific flexible content rows

  • Hello guys and gals,

    I have been trying to do this thing for a while now but cannot seem to get this one thing right. Basically i want to create a front-end form for each layout row of a ACF flexible content field. I can save values into the right fields, the problem is, that the fields of the acf_form are always empty. Here is my code:

    
    if( have_rows('flexible_content') ):
        while ( have_rows('flexible_content') ) : the_row();
            if( get_row_layout() != '' ) {
                echo '<section class="m-'.get_row_layout().' module">';
    
                // Module Settings
                if( is_user_logged_in() ) {
    
                    $row = get_row(); // get row
                    unset($row['acf_fc_layout']); // only fields and values
    
                    // settings for the fields of this layout row
                    $settings = array(
                        'fields' => array_keys($row),
                        'honeypot' => false             // remove honeypot, it is not needed
                    );
    
                    acf_form( $settings );      // create the form
                }
    
                // Module
                vs_include_module(get_row_layout() ); // include template with some function
    
                echo '</section>';
    
                $row_counter++;
            }
        endwhile;
    endif;

    Do you have any idea, how i might get the values for each row into the forms? I think i am just loading the fields without the content. Any help would be greatly appreciated.

    Cheers

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.