AdvancedCustomFields / AdvancedCustomFields/acf
Defining post_title in hidden frontend form no longer possible
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:
- 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.
- Submit the form
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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