Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

In a installation profile, how do I fill values for Set up database step programmatically and hide it so user doesn't need to fill the form?

How to do the above action for the Select language step?

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted
+50

You wanted an example -- which is basically showing you how to do it. From the docs I supplied and the help others that gave you cookie crumbs provided should have lead you towards a solution, Other than saying "show me" all the code.

A working profile example is in this GIST, you make a shortprofile directory in your /profiles directory and select "Short Profile" from the Installation screen. This is the "long way" to do this, there is a shorter way in-theory ... see my code comments.

Be sure to change the $databases['default']['default'] in line 47 of .profile to the existing database credentials that will work in your environment. Look for my comments in the code to change the db credentials and db password (line 125 of .profile).

share|improve this answer
    
for the Locale stuff I would do a custom system_form_install_select_locale_form_alter() in your .profile file and provide the default value you want. –  tenken Mar 29 '12 at 22:52
add comment

Fair warning I haven' done this before (but I have made install profiles and used them via Drush Make). So I was interested in how you might try to do this ...

I found this documentation page, How To Write a Drupal 7 Installation Profile

I assume you are using the 'Miminal' or 'Standard' defaults in your profile to save you some headache, or else you'd know the answer to your own question in building a complete profile from scratch ... I think you need to do 2 things:

(1) If you're using the minimal or standard defaults you can use hook_install_tasks_alter() to change the visibility of the database Step to hidden. If your defining your own install tasks via hook_install_tasks() in yourprofile.profile

(2) You need to provide the database parameters. You can do that probably most straight-forwardly via hook_form_alter() as described in the documentation page linked above. You may also be able to muck with the values in $install_state for hook_install_tasks as described in install_state_defaults()

I suggest you read up on all these hook functions and the documentation page above. good luck.

share|improve this answer
    
Thanks, I know about hooks you mentioned. I need more details on how to set database parameters. –  hknik Mar 29 '12 at 14:46
add comment

Database credentials are set in settings.php. So you'd provide a settings.php with your distribution, or you'd write out the db array to the settings.php at some point during installation.

You could do this in an installation profile, with hook_install_tasks_alter(), by changing install_settings_form.

Same caveats as tenken... I haven't done this.

share|improve this answer
1  
I have done this, and it works; Drupal will skip the database configuration page on install if the database settings are already configured in settings.php. I have not tried this on D7 (I mostly use drush site-install nowadays), but it should still work. One problem on D6 which may or may not be fixed on D7: if you navigate to mysite.org when it is NOT installed, then you will see many errors; you must go to mysite.org/install.php directly. –  greg_1_anderson Mar 29 '12 at 18:19
    
"You could do this in an installation profile, with hook_install_tasks_alter(), by changing install_settings_form." This is my question! how to do this with hook_install_tasks_alter()? Can you provide an example? –  hknik Mar 29 '12 at 18:45
    
as @greg_1_anderson says using settings.php causes errors until user enters example.com/install.php –  hknik Mar 29 '12 at 18:47
    
Right. That's how you install Drupal. :-) –  paul-m Apr 7 '12 at 17:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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