• I’m trying to move away from Frontend Admin for ACF (FAFA) (a plugin for Elementor) to ACF Extended Forms.

    In all the tutorials I’ve seen, a CPT gets what I thought were default fields for example my_cpt_title and my_cpt_content which are then mapped to the post title and content respectively. I thought that if you create a CPT the Title and Content fields are created automatically, and when I want to add a post title for instance in FAFA, I select the default Title field, not an additional field in my CPT.

    Is this wrong, do I have to use a CPT field for the default wordpress fields when using ACF Extended forms?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    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.

    Thread Starter pzh20

    (@pzh20)

    Thanks for this Konrad,

    I don’t mind having to use fields in the Field Group for the Title and Content, especially if they are mapped to the WordPress fields so they show correctly in the backend, it’s just that the Frontend Admin Pro for ACF Pro plugin allows the WordPress Title fields and Content fields to be included directly in the front end.

    Anyway, I can set these field up.

    REgards
    Pete

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    There are multiple reasons for not using a pre-built “Title + Content” in the form.

    Reason 1: It’s a partial solution
    Title & Content are not the only native WP Post fields. There is also: Slug, Featured Image, Post Type, Post Author, Post Parent, Post Terms etc… Each one having their own Field Type (image, text, textarea, WYSIWYG, select, radio, checkbox), their own settings (max length, min/max selection, required/optional…).

    Why only adding Title + Content, when some users will also want the others? A partial solution isn’t really appealing.

    Reason 2: Lack of customization
    Developers will want to customize each one of the fields listed above. Including changing their Type and their Settings. If the form doesn’t allow it, users will ask for it. If the Form allows it, then the Form UI essentially becomes a Field Group UI clone.

    So the user ends up with two UI doing the same thing, and they will probably get lost. Not to mention third party plugins which add custom settings to ACF Fields, or new ACF Fields such as the ACF FontAwesome picker. These should be imported and maintained in the Form UI.

    Reason 3: Lack of consistency
    ACFE Form has the unique approach to allow multiple actions within one single form submission. For example: Create a post > then create a user > then send an email > then send an another email > then create an another post etc… “Create Post” is just an action among the others.

    The fields displayed on the front-end are not controlled by those Actions. It’s the job of the Form wrapper itself. That’s why having a “Add Post Title” setting in the “Post Action” doesn’t make sense, because that field can then later be used as a Username in the “User Action”, and then as Subject in the “Email Action”.

    Let’s say you have 3 different “Post Create” actions within a single form. Which one should use the “Add Post Title” setting? If the user use this setting in the first & second action, it should display a title field two times? Or only one time? This is inconsistant within the ACFE Form logic.

    Hope it’s more clear.

    Have a nice day!

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Confused over default title and contect’ is closed to new replies.