Home › Forums › General Issues › Using acf_form – add post title… › Reply To: Using acf_form – add post title…
I am using the 'form' => false,
option to provide the ACF fields within my own form HTML.
I just added my own plain html field with the id acf-_post_title and name acf[_post_title] and everything worked as expected.
<input type="hidden" id="acf-_post_title" name="acf[_post_title]" value="Anonymous Response">
I provided a default title that worked for me, and then used a bit of jQuery to change the value based on user input to other fields. My example fills in the first and last name fields if they are not empty and if an anonymous checkbox is not checked.
$('#acf-field_590bacbe30591, #acf-field_590bacd630592, #acf-field_590bad1230595').on('change', function() {
var fname = $('#acf-field_590bacbe30591').val();
var lname = $('#acf-field_590bacd630592').val();
var anon = $('#acf-field_590bad1230595').attr('checked');
if ( anon == 'checked' || ( fname == '' && lname == '' ) ) {
$('#acf-_post_title').val("Anonymous Response");
}
else {
$('#acf-_post_title').val("Response from " + fname + " " + lname);
}
});
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.