14. Layout Fields (Tab, Accordion, Message) | Field Forge - Custom Fields, Built for Speed
Download Log in

14. Layout Fields (Tab, Accordion, Message)

Developer Guide

These fields do not store values. They control the admin UI layout and organization.

Field TypePurposeTemplate Code
TabGroups fields into tabs in the editorNone needed
AccordionGroups fields into collapsible sectionsNone needed
MessageDisplays a read-only message/instructions in the editorNone needed

Layout fields are configured in the field group definition and affect only the WordPress admin interface. They have no output in templates. Use them to organize complex field groups into logical sections.

php
// Example: Creating a field group with tabs programmatically
FIELDFORGE_Field_Groups::instance()->create( [
    'title'  => 'Product Details',
    'fields' => [
        // Tab: General
        [ 'key' => 'field_tab_general', 'label' => 'General', 'type' => 'tab' ],
        [ 'key' => 'field_title', 'label' => 'Title', 'name' => 'product_title', 'type' => 'text' ],
        [ 'key' => 'field_desc', 'label' => 'Description', 'name' => 'product_desc', 'type' => 'textarea' ],

        // Tab: Pricing
        [ 'key' => 'field_tab_pricing', 'label' => 'Pricing', 'type' => 'tab' ],
        [ 'key' => 'field_price', 'label' => 'Price', 'name' => 'price', 'type' => 'number' ],
        [ 'key' => 'field_sale', 'label' => 'Sale Price', 'name' => 'sale_price', 'type' => 'number' ],

        // Tab: Media
        [ 'key' => 'field_tab_media', 'label' => 'Media', 'type' => 'tab' ],
        [ 'key' => 'field_gallery', 'label' => 'Gallery', 'name' => 'gallery', 'type' => 'gallery' ],

        // Message field for instructions
        [ 'key' => 'field_msg', 'label' => 'Note', 'type' => 'message', 'message' => 'Upload at least 3 product images.' ],
    ],
    'location_rules' => [
        [ [ 'param' => 'post_type', 'operator' => '==', 'value' => 'product' ] ],
    ],
] );

Forge AI Assistant Online

Hi! I'm the Field Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs