ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Feature Request: ability to add extra Fieldtype categories to statamic.

Open leon-fablr opened this issue 4 months ago • 0 comments

From what I can tell the standard set of categories that can be assigned to Fieldtypes is not changeable. So if you use anything besides text, controls, media, number, relationship, structured or special the Fieldtype is just added to special as a catch-all when you go to select a field type in the control panel.

So currently if you add something like:

<?php

namespace App\Fieldtypes;

use Statamic\Fields\Fieldtype;

class DisplayWysiwygContentInAForm extends Fieldtype
{
    protected $categories = ['static_content'];
    protected $selectable = false;
    protected $selectableInForms = true;
}

You will end up with field with handle display_wysiwyg_content_in_a_form inside the special category.

I think this is in part due to this being hard-coded in vendor/statamic/cms/resources/js/components/fields/FieldtypeSelector.vue (I still haven't got my head around vue and modifying the control panel so may have not understood this correctly).

export default {
    //....
    data: function() {
        return {
            categories: {
                text: {
                    title: __('Text & Rich Content'),
                    description: __('fieldtypes.picker.category.text.description'),
                },
                controls: {
                    title: __('Buttons & Controls'),
                    description: __('fieldtypes.picker.category.controls.description'),
                },
                media: {
                    title: __('Media'),
                    description: __('fieldtypes.picker.category.media.description'),
                },
                number: {
                    title: __('Number'),
                    description: __('fieldtypes.picker.category.number.description'),
                },
                relationship: {
                    title: __('Relationship'),
                    description: __('fieldtypes.picker.category.relationship.description'),
                },
                structured: {
                    title: __('Structured'),
                    description: __('fieldtypes.picker.category.structured.description'),
                },
                special: {
                    title: __('Special'),
                    description: __('fieldtypes.picker.category.special.description'),
                },
            },
            search: ''
        }
    },

It would be nice to have some way of registering additional categories we can use. It seems like they need a handle/key, a title and a description. Perhaps add some facade somewhere to allow for this?

leon-fablr avatar Sep 09 '25 16:09 leon-fablr