I'm trying to create a .install for a module that I'm migrating from Drupal 6. It requires two 'profile fields', which, in drupal 6, it checked for and created automatically.
To upgrade it to drupal 7 I'm trying to do this with fields! Easy enough right?
So far I have
if(!field_info_field('user_fullname')) {
$field = array(
'field_name' => 'user_fullname',
'type' => 'text',
'settings' => array(
'required' => TRUE,
),
);
field_create_field($field);
$instance = array(
'field_name' => 'user_fullname',
'entity_type' => 'user',
'label' => 'The user\'s full name',
'bundle' => 'additional_info',
'required' => true,
'widget' => array(
'type'=>'options_select',
)
);
field_create_instance($instance);
}
Which, sure enough, creates the field, but it's not visible in the user's profile?
Do I need something additional for that? If so, What?
Many Thanks.
SOLVED: It was due to the bundle (not entirely sure what a bundle is really), I changed the bundle to 'user' and it appeared!
bundle is pretty much the same as content type. But since in D7 users are entities too, but they are not content, using the term 'content type' didn't make sense. Reference: Barry Jaspan's DrupalCon Paris 2009 Session: Intro to the Field API for Module Developers.
Intro to the Field API for Module Developers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With