I want to create some profile fields in an install file and am trying to use the following code, but it does not seem to work. If I do this in a module file it does work. Any ideas you drupal ninjas?

function enquiry_basket_install()
{

$form_values = array(
'title' => 'Title',
'name' => 'title',
'explanation' => 'Your salutation',
'category' => 'Personal Details',
'type' => 'selection',
'weight' => '0',
'required' => '1',
'register' => '1',
'visibility' => '1',
'autocomplete' => '0',
'options' => "Mr\nMrs\nMiss\nDr",
'page' => ''
);

profile_field_form_submit(1, $form_values);

}

Comments

pdjohnson’s picture

Actually - it seems that when I install this module on another site it works. I am guessing that the _install function executes once only per install. I was disabling and re-enabling the module. This does not seem to trigger the _install.

--Paul Johnson

gpk’s picture

Correct, hook_install() http://api.drupal.org/api/function/hook_install/5 only fires on first installation. To get it to run again, either manually remove the module's row from the {system} table, or implement the uninstall hook http://api.drupal.org/api/function/hook_uninstall/5 and then use the Uninstall tab at the top of the admin/build/modules page. Even if this does nothing, it will cause the system automatically to do the same.

gpk
----
www.alexoria.co.uk