Home › Forums › Front-end Issues › 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?
I’ll tag @elliot in on this. This sounds like just a miss in attempting to simplify the codebase 🙂
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.
The topic ‘Front end form no longer rendering fields’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.