1

I created the custom field for existing entity, I can see those fields listed on 'field_info_instances()' . And I also have data in those fields, but I can't see those fields listed on the entity object returned by entity_load().

This is how I am installing the fields

/**
 * Implements hook_update_N()
 */
function dashboard_update_7002() { 

        field_create_field( array(
            'field_name' => "dashboard_url",
            'type' => 'text',
            'cardinality' => 1,
            'entity_types' => array('manufacturer'),
            'translatable' => TRUE,
            'locked' => true,
        ));

        field_create_instance(array(
            'field_name' => "dashboard_url",
            'entity_type' => 'manufacturer',
            'bundle' => 'manufacturer',
            'label' => "Dasboard URL",
            'required' => FALSE,
            'widget' => array(
                'type' => 'text_textfield',
            )
        ));

    }   
}

1 Answer 1

2

After banging my head for a while, I found the solution. On the module where that entity was defined 'hook_entity_info()', 'fieldable' property was missing which is set to FALSE by default. Therefore none of the fields were being attached to that entity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.