Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

🤖 Skip the Field UI. ⏲️ Save time. 🏡 Enjoy life!

This module allows you to create fields quickly from YAML or JSON files or from an array in your module.

It is particularly helpful in one of these situations:

💡 Starting a Drupal project and planning content structure
🤞 Creating the same fields across many content types
🎨 Decoupled architecture where front-end development takes place first
(allows potentially non-Drupal developers to work with real content and markup)
🥱 Tired of clicking around in the admin to create/place fields

How to use

With a custom module

In your own custom module, you can either (option 1) place custom configuration files in the install folder and/or (option 2) implement a hook to declare your fields.

  • Option 1: in /mymodule/config/install/field_create.node.settings.yml
    demo_field:
      name: demo_field
      label: This is my field
      type: string
      force: true
      bundles:
        page:
          label: This is a custom label for Pages
        article:
          label: This is a custom label for Articles
    

    Now either a) enable your module to automatically import the config or b) import the configuration manually drush cim --partial --source=modules/custom/mymodule/config/install

  • Option 2: in /mymodule/mymodule.module file
    /**
     * Implements hook_field_create_definitions().
     */
    function mymodule_field_create_definitions_alter(array &$definitions) {
      // Define your fields here by entity type.
      $definitions['node'] = [
        'demo_field' => [
          'name'    => 'demo_field',
          'label'   => 'This is my field',
          'type'    => 'string',
          'force'   => FALSE, // No update once field exists.
          'bundles' => [
            'page' => [],
            'article' => [],
          ],
        ],
      ];
    }
    

With the admin UI

Visit the admin settings page at Configuration > Development > Create Field Programmatically and paste your custom YAML configuration to declare your fields.

Note: an example file exists with detailed explanations about the custom YAML configuration. See the module's folder /example/field_create.node.settings.yml

Alternatively, you can enable the field_create_from_json submodule to convert JSON to YAML. An example file exists in the submodule's folder too at /example/node_fields.json

Create fields

With custom configurations in database AND with the module enabled in core.extensions.yml, you can now import your fields. Simply run this Drush command to create and/or to update your fields:

drush field_create

You can filter the field creation by entity type as follow:

drush field_create --entity-type-id node

Removing the module

You should remove this module once your fields are created as it is not meant to be deployed to realworld websites. This is only a developer tool :)

So uninstall the module if you don't need it anymore.

drush pmu field_create

Warning: all configurations for this module are deleted during the uninstall process (see details in the field_create_uninstall()).

---

This module is meant for development purpose only. You should not use it on production.

Related projects

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Oct 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core Release date
1.0.2 Stable Oct 12, 2023
1.0.1 Stable Oct 9, 2023