Relating to the excellent features added in #1198956: Site Install: allow passing additional form parameters;

I have a site install option in my .profile file that has a checkbox with default set to true:

$form['checkbox_item'] = array(
    '#title' => st('Install custom config set'),
    '#type' => 'checkbox',
    '#default_value' => TRUE,
  );

In drush site-install, I would like to set it to false. However it is not as easy as: providing key value pairs such as :
drush site-install standard my_profile_form.checkbox_item=FALSE
or
drush site-install standard my_profile_form.checkbox_item=''

This is because of the quirks of 'checkbox' input type and its return of value - see the implementation of form_type_checkbox_value() and the comments within for more information.

I found a reasonable workaround to get going - by not passing the value to the key in the call:
drush site-install standard my_profile_form.checkbox_item
(although, it does throw a warning: "undefined offset: 1 site_install.drush.inc:126")

Trying to come up with a better solution is tricky as the roots of the problem lie elsewhere.

Comments

greg.1.anderson’s picture

Two ideas. One, we could add special values just to site-install that convert "CHECKED" and "UNCHECKED" (case-sensitive strings) to TRUE and FALSE, respectively.

The other thought would be to have generic special checking, maybe "TRUE" and "FALSE" or "#TRUE" and "#FALSE", to allow users to specify boolean values in command line options wherever they are needed.

Thoughts?

girishmuraly’s picture

To expand on that thought:

Using myself as a guinea-pig, the options I went through to set the checkbox_item to false (unchecked) were:

drush site-install standard my_profile_form.checkbox_item=FALSE
drush site-install standard my_profile_form.checkbox_item=''
drush site-install standard my_profile_form.checkbox_item="FALSE"
drush site-install standard my_profile_form.checkbox_item=

Which goes to say we could consider all the above to mean the value is FALSE (implicit conversion in code). This does not introduce special cases for the user to remember. Everything else can be considered as a real value (which evaluates to TRUE for booleans and passed as-is for other FAPI types).

Perhaps its not required to have the above conditional conversion to apply for checkbox elements alone or even for site-install command even? It could be for any drush option and would help to pass boolean FALSE as value.

girishmuraly’s picture

Version: All-versions-4.x-dev »

This issue has not received attention for a long time. Is there a resolution somewhere?

moshe weitzman’s picture

No other resolution. Patches welcome. I have no particular opinion on how it gets implemented.

greg.1.anderson’s picture

Version: » 8.x-6.x-dev
Status: Active » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If desired, you may copy this bug to our Github project and then post a link here to the new issue. Please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.

greg.1.anderson’s picture

Issue summary: View changes

Updated issue summary.