mcpField
D
drupal-fields

drupal-fields

github.com/edutrulDevelopment7349 installsUpdated 21w ago
Repository

About drupal-fields

drupal-fields is a Drupal development skill covering field creation and management, configuration export, custom field plugins, and accessing field values. It is intended for developers working with Drupal fields through Drush and PHP.

Key features

  1. 01Create fields with Drush
  2. 02List and delete fields
  3. 03Export configuration after CLI changes
  4. 04Generate field type, formatter, and widget plugins
  5. 05Read single, referenced, and multiple values

Use cases

  1. 01Add a field to a content type
  2. 02Inspect or remove an existing field
  3. 03Implement a custom field plugin
  4. 04Read field data in PHP

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/edutrul/drupal-ai --skill drupal-fields

After installing, type/drupal-fieldsin Claude Code to confirm it loaded.

Bundled filesREADME.md

Details

From the project README

Drupal Fields

Creating Fields (Drush — CLI First)

Always use drush field:create instead of manually creating field config files.

# Interactive (recommended first time)
drush field:create

# Non-interactive
drush field:create node article \
  --field-name=field_subtitle \
  --field-label="Subtitle" \
  --field-type=string \
  --field-widget=string_textfield \
  --is-required=0 \
  --cardinality=1

# Reference field
drush field:create node article \
  --field-name=field_tags \
  --field-label="Tags" \
  --field-type=entity_reference \
  --field-widget=entity_reference_autocomplete \
  --cardinality=-1 \
  --target-type=taxonomy_term

# Image field
drush field:create node article \
  --field-name=field_image \
  --field-label="Image" \
  --field-type=image \
  --field-widget=image_image \
  --is-required=0 \
  --cardinality=1

Managing Fields

# List all fields on a content type
drush field:info node article

# Delete a field
drush field:delete node.article.field_subtitle

# Discover available types/widgets/formatters
drush field:types
drush field:widgets
drush field:formatters

Export After Creating Fields

# Always export config after CLI changes
drush config:export -y

Custom Field Type (Plugin)

drush generate plugin:field:type
drush generate plugin:field:formatter
drush generate plugin:field:widget

Accessing Field Values in Code

// Single value
$value = $entity->get('field_name')->value;

// Entity reference
$referenced = $entity->get('field_ref')->entity;

// Multi-value
foreach ($entity->get('field_multi') as $item) {
  $value = $item->value;
}

Comments

Markdown supported