Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8408735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:42:55+00:00 2026-06-09T23:42:55+00:00

My module defines a custom field type with hook_field_info() . In hook_install() of this

  • 0

My module defines a custom field type with hook_field_info(). In hook_install() of this module, I am trying to create new fields and instances of this custom field type:

function my_module_install() {

  if (!field_info_field('my_field')) {
    $field = array(
      'field_name' => 'my_field',
      'type' => 'custom_field_type',
      'cardinality' => 1
    );
    field_create_field($field);
  }
}

The code crashes at field_create_field($field):

WD php: FieldException: Attempt to create a field of unknown type custom_field_type. in field_create_field() (line 110 of                                            [error]
/path/to/modules/field/field.crud.inc).
Cannot modify header information - headers already sent by (output started at /path/to/drush/includes/output.inc:37) bootstrap.inc:1255                             [warning]
FieldException: Attempt to create a field of unknown type <em class="placeholder">custom_field_type</em>. in field_create_field() (line 110 of /path/to/modules/field/field.crud.inc).

What’s wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:42:56+00:00Added an answer on June 9, 2026 at 11:42 pm

    You are trying to enable a module that defines field types and attempts to use those same field types in its hook_install(), before it’s enabled. Drupal’s field info cache is not rebuilt before hook_install() is run, so Drupal does not know about the field types in your module when you’re trying to create your field.

    To get around this, manually rebuild the field info cache by calling field_info_cache_clear() before field_create_field($field):

    if (!field_info_field('my_field')) {
      field_info_cache_clear();
    
      $field = array(
        'field_name' => 'my_field',
        'type' => 'custom_field_type',
        'cardinality' => 1
      );
      field_create_field($field);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a new custom module in magento but the layout
I've created a custom module (which currently only defines a new Exception class), and
I'd like to call a custom function that is defined in a Python module
I am building a custom ,module with a custom content type. I have defined
I want to add one new custom field to one page checkout in Magento.
I am attempting to develop a Drupal module that defines the class MyFeedsSyndicationParser. This
I've added custom attribute to orders using mysql4-install-1.0.0.php in my module: $installer = $this;
`I've installed the DateTime Field module to Orchard and assigned two fields to my
I'm trying to create a custom 404 page in my admin when something goes
I'm following this tutorial http://codemagento.com/2011/03/creating-custom-magento-reports/ creating the simple report module. I have all the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.