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);