Skip to main content
added 795 characters in body
Source Link
Immers
  • 603
  • 7
  • 29

I tried copying the functions from the field module in example modules to get a field to show up in Manage Fields without necessarily any functionality

Looking at the answer to this question, only field_create_field() and hook_field_info() should do the trick but I never got that working with the following code:

function entityreference_add_new_field_info() { return array( 'entityreference_add_link' => array( 'label' => t('Entityreference link'), 'description' => t('Entityreference link'), 'default_widget' => 'entityreference_link_widget', 'default_formatter' => 'entityreference_link_formatter', ), ); field_create_field('entityreference_add_link'); } 

Putting field_create_field() outside of hook_field_info() returns 'call to undefined function' error.

Update: Here's one thing I've tried without success:

function entityreference_add_new_field_info() { return array( 'entityreference_add_link' => array( 'label' => t('Entityreference link'), 'description' => t('Entityreference link'), 'default_widget' => 'entityreference_link_widget', 'default_formatter' => 'entityreference_link_formatter', ), ); field_create_field('entityreference_add_link'); $instance = array( 'field_name' => 'entityrefernce_add_link', 'entity_type' => 'node', 'label' => 'The Link', 'bundle' => 'node', ); field_create_instance($instance); } enter code here 

I tried copying the functions from the field module in example modules to get a field to show up in Manage Fields without necessarily any functionality

Looking at the answer to this question, only field_create_field() and hook_field_info() should do the trick but I never got that working with the following code:

function entityreference_add_new_field_info() { return array( 'entityreference_add_link' => array( 'label' => t('Entityreference link'), 'description' => t('Entityreference link'), 'default_widget' => 'entityreference_link_widget', 'default_formatter' => 'entityreference_link_formatter', ), ); field_create_field('entityreference_add_link'); } 

Putting field_create_field() outside of hook_field_info() returns 'call to undefined function' error.

I tried copying the functions from the field module in example modules to get a field to show up in Manage Fields without necessarily any functionality

Looking at the answer to this question, only field_create_field() and hook_field_info() should do the trick but I never got that working with the following code:

function entityreference_add_new_field_info() { return array( 'entityreference_add_link' => array( 'label' => t('Entityreference link'), 'description' => t('Entityreference link'), 'default_widget' => 'entityreference_link_widget', 'default_formatter' => 'entityreference_link_formatter', ), ); field_create_field('entityreference_add_link'); } 

Putting field_create_field() outside of hook_field_info() returns 'call to undefined function' error.

Update: Here's one thing I've tried without success:

function entityreference_add_new_field_info() { return array( 'entityreference_add_link' => array( 'label' => t('Entityreference link'), 'description' => t('Entityreference link'), 'default_widget' => 'entityreference_link_widget', 'default_formatter' => 'entityreference_link_formatter', ), ); field_create_field('entityreference_add_link'); $instance = array( 'field_name' => 'entityrefernce_add_link', 'entity_type' => 'node', 'label' => 'The Link', 'bundle' => 'node', ); field_create_instance($instance); } enter code here 
Source Link
Immers
  • 603
  • 7
  • 29

What's the minimum amount of code needed to have a field show up in Manage Fields?

I tried copying the functions from the field module in example modules to get a field to show up in Manage Fields without necessarily any functionality

Looking at the answer to this question, only field_create_field() and hook_field_info() should do the trick but I never got that working with the following code:

function entityreference_add_new_field_info() { return array( 'entityreference_add_link' => array( 'label' => t('Entityreference link'), 'description' => t('Entityreference link'), 'default_widget' => 'entityreference_link_widget', 'default_formatter' => 'entityreference_link_formatter', ), ); field_create_field('entityreference_add_link'); } 

Putting field_create_field() outside of hook_field_info() returns 'call to undefined function' error.