Support

Account

Home Forums Front-end Issues Front end form no longer rendering fields

Solved

Front end form no longer rendering fields

  • A form which has always previously rendered and functioned correctly has suddenly stopped working, probably due to a recent upgrade to ACF. I am passing specific fields in the acf_form arguments as follows:

    
    'fields'=>array(
            'first_name'
            ,'last_name'
            ,'date_of_birth'
            ,'tshirt_size'
    )
    

    These fields have suddenly stopped rendering. I’ve traced the code through the live plugin and compared it to my local copy and there’s a difference which appears to be the cause.

    Line 1370 of api-template.php reads as follows:

    
    $fields[] = get_field_object( $selector, $post_id, false, false );
    

    whereas the equivalent line in my older version reads as:

    
    $fields[] = acf_get_field( $selector );
    

    If I omit the fields argument then the form renders correctly, but there’s an admin-only field that we don’t want to be displaying to front-end users.

    I have tried replacing this line on my live site and the form appears to be restored correctly.
    Obviously that’s not going to survive a further update to ACF, so what should I have done; or is this a mistake in the latest code?

  • Hi @thisleenoble

    I’ll tag @elliot in on this. This sounds like just a miss in attempting to simplify the codebase 🙂

  • Any confirmation yet that this is a bug within ACF?

  • Hi guys,

    Interesting. I can see the issue, and will add this to my to-do for the next coming version.

    Cheers
    E

  • Hi guys,

    The reason for the change in code was to prevent ACF from rendering the wrong fields. Because you are using field names (instead of field keys), ACF may actually find multiple fields, and return the incorrect one.

    For example, you may have 2 different fields with different settings for ‘first_name’.

    I’ve loosened this strict logic to allow ACF to find fields via name, so this should no longer be an issue in the next version

  • Great! Thank you @elliot


    @thisleenoble
    this should then solve your issue. If you’re in need of further help using ACF feel free to post another topic and we’ll surely help you.

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

The topic ‘Front end form no longer rendering fields’ is closed to new replies.