Hello,
Thanks for the feedback!
In fact, in order to allow full control over fields types (text, textarea, editor…), their settings (required, max length…) and their placement in the form, you’ll have to create your own “Title” & “Content” fields.
There are different ways to achieve it.
Solution 1:
Create a “dummy” Field Group with the “Title” and the “Content” fields. Set the Field Group as disabled so it’s never displayed in the back-end. Then in the Form UI, map the dummy Field Group + the actual Field Group with your ACF fields. Both will be displayed on the front-end.
Additionally, you can choose which field is displayed at which place using the “Override HTML Render” in the “HTML” tab. Here you’ll be able to write down HTML and include the fields of your choices.
If you don’t want to polute your Field Groups UI list with this dummy Field Group, you could export it in PHP, paste the code in your theme’s functions.php
file and forget it. It will be always available for any form you create.
Here is one you could use right now:
add_action('acf/init', 'my_acfe_form_title_content');
function my_acfe_form_title_content(){
acf_add_local_field_group(array(
'key' => 'group_my_acfe_form_title_content',
'title' => 'Title + Content',
'fields' => array(
array(
'key' => 'field_title',
'label' => 'Title',
'name' => 'title',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
),
array(
'key' => 'field_content',
'label' => 'Content',
'name' => 'content',
'type' => 'textarea',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'rows' => '',
'placeholder' => '',
'new_lines' => '',
),
),
'location' => array(),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'left',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => false,
'description' => '',
'show_in_rest' => 0,
));
}
Here is the result when used in the ACFE Form UI.
Solution 2:
Integrate your “Title” and “Content” fields directly in your Field Group, so they are displayed on the front-end. To hide them in the back-end, you can choose one of the following method:
Why this methodology?
ACFE Form is designed for advanced usage, giving complete control to developers to choose which field is displayed where, which one is saved, which one isn’t, which one is a dummy field etc… In fact, there are numerous use cases where the Post Title and Content aren’t required, to name a few:
- When creating a ticket system (Generated id as title)
- When generating an invoice (#Generated id as title)
- When generating a User Profile page (Firstname + Lastname as title)
I hope it’s now more clear!
Have a nice day!
Regards.