AdvancedCustomFields / AdvancedCustomFields/acf

Defining post_title in hidden frontend form no longer possible

Open Beginner friendly
#1,019 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
945
Forks
197
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
I had a frontend form with a default post_title defined in a hidden form field added like so:
'html_before_fields' => '<input type="hidden" id="acf-_post_title" name="acf[_post_title]" value="Default Title">'. Submissions now have "(no title)" because line 278 of form-front.php requires the post_title argument to be true.

To Reproduce
Steps to reproduce the behavior:

  1. Create a frontend form using acf_form() that creates a new post, and make sure post_title is set to the default of false and you have added a hidden post_title field as described above.
  2. Submit the form
  3. Observe that the new post's title is "(no title)" rather than the one you defined in your hidden field.

Expected behavior
I expect the hidden field title to carry through to the post.

Version Information:

  • WordPress Version [7.0]
  • PHP Version [8.2]
  • ACF Version [ACF PRO 6.8.4]
  • Browser [Chromium 149.0.7827.196 ]

Additional context
I realize this isn't standard functionality but it's a method devs have used.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in form-front.php around line 278 and trace how acf_form() handles the post_title argument and submitted hidden fields. Reproduce the reported frontend form case, then verify that a hidden acf[_post_title] value is preserved when post_title is false and the new post receives that title.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.