Support

Account

Home Forums Front-end Issues acf_form 'field_groups' order

Solving

acf_form 'field_groups' order

  • I want to display the custom fields at front-end.
    So i am using acf_form() function.

    In my php code i have defined

    $options = array(
    			'post_id'		=> 'new_post',
    			'form' => false,
    			'field_groups' => array(77,8),
    			'post_title'	=> false,
    			'post_content'	=> false,
    			'html_before_fields' => $html_before_fields,
    			'html_after_fields' => $html_after_fields,
    			'instruction_placement' => 'field',
    			'submit_value'	=> 'Submit',
    			'updated_message'	=> 'Record Added Successfully',
    		);

    But at front-end, fields of group “8” are displayed first and group “77” second.
    I want the fields to be displayed in the same order as mentioned in ‘field_groups’.

  • Hi @amritdeepkaur

    I’ve just tested it on my installation and the field groups show up in the same order as mentioned in the ‘field_groups’ option. Maybe there’s something on your site that modifies the order. Could you please try to reproduce the issue on one of the WordPress’ stock themes (like Twenty Sixteen) with other plugins deactivated? If it disappears, then you can activate the theme and plugins one by one to see which one causes the issue.

    Thanks 🙂

  • Wordpress version : 4.6.1

    ACF version : 4.4.10

    Theme : Twenty Fifteen

    Active Plugin : Advanced Custom Fields

     'field_groups' => array(77,8), 
    OR
     'field_groups' => array(8,77),

    display the same output at my end. Will you please check it again.

  • Have a look on screenshots….

  • Hi @amritdeepkaur

    I’m sorry I was testing it with ACF PRO version. With the free version, it seems you need to set the Order No. option on the field group editor page (under the Location option). Could you please set it and test it again?

    Thanks 🙂

  • But in my case,
    I have created some surveys with ACF.
    Sometimes in survey i need the order like

    'field_groups' => array(1,2,3,4)

    and sometimes in another survey i need the order like

    'field_groups' => array(3,1,2,4),

    and sometimes

    'field_groups' => array(1,4,3,2),
    and so on…..

    Set the Order No. does not solve my problem. Please suggest me what to do…..

  • Hi @amritdeepkaur

    Another method would be adding the form one by one with form option set to false. Maybe something like this:

    <form id="post" class="acf-form" action="" method="post">
    
        <?php
        acf_form(array(
            'field_groups' => array(77),
            'form' => false,
        ));
        acf_form(array(
            'field_groups' => array(8),
            'form' => false,
        ));
        ?>
    
        <div class="field">
            <input type="submit" value="Update">
        </div>
        
    </form>

    But the easiest way would be using the PRO version instead as you will get better features.

    Thanks 🙂

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

The topic ‘acf_form 'field_groups' order’ is closed to new replies.