Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.289 diff -u -p -r1.289 form.inc --- includes/form.inc 27 Sep 2008 19:47:42 -0000 1.289 +++ includes/form.inc 30 Sep 2008 16:59:37 -0000 @@ -1755,7 +1755,7 @@ function form_process_radios($element) { /** * Add input format selector to text elements with the #input_format property. * - * The #input_format property should be the ID of an input format, found in + * The #input_format property should be the ID of an input format, found in * {filter_formats}.format, which gets passed to filter_form(). * * If the property #input_format is set, the form element will be expanded into @@ -1771,7 +1771,7 @@ function form_process_radios($element) { * '#type' => 'textarea', * '#title' => t('Body'), * '#input_format' => isset($node->format) ? $node->format : FILTER_FORMAT_DEFAULT, - * ); + * ); * @endcode * * Becomes: @@ -2343,6 +2343,21 @@ function form_clean_id($id = NULL, $flus } /** + * Filter out a form element's array keys that have empty values. + * + * This replaces the FAPI hack $form['array_filter'] with the more elegant + * $form['item']['#element_validate'] = array('drupal_filter_form_array'); + * + * @param $element + * An associative array containing the structure of the form element. + * @param $form_state + * A keyed array containing the current state of the form. + */ +function drupal_filter_form_array($element, &$form_state) { + $form_state['values'][$element['#name']] = array_keys(array_filter($form_state['values'][$element['#name']])); +} + +/** * @} End of "defgroup form_api". */ Index: modules/book/book.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.admin.inc,v retrieving revision 1.12 diff -u -p -r1.12 book.admin.inc --- modules/book/book.admin.inc 5 Jul 2008 06:00:51 -0000 1.12 +++ modules/book/book.admin.inc 30 Sep 2008 16:59:40 -0000 @@ -35,6 +35,7 @@ function book_admin_settings() { '#options' => $types, '#description' => t('Select content types which users with the %add-perm permission will be allowed to add to the book hierarchy. Users with the %outline-perm permission can add all content types.', array('%add-perm' => t('add content to books'), '%outline-perm' => t('administer book outlines'))), '#required' => TRUE, + '#element_validate' => array('drupal_filter_form_array'), ); $form['book_child_type'] = array( '#type' => 'radios', @@ -44,7 +45,6 @@ function book_admin_settings() { '#description' => t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', array('%add-child' => t('Add child page'))), '#required' => TRUE, ); - $form['array_filter'] = array('#type' => 'value', '#value' => TRUE); $form['#validate'][] = 'book_admin_settings_validate'; return system_settings_form($form); @@ -250,4 +250,3 @@ function theme_book_admin_table($form) { return theme('table', $header, $rows, array('id' => 'book-outline')); } - Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.269 diff -u -p -r1.269 system.install --- modules/system/system.install 27 Sep 2008 20:16:17 -0000 1.269 +++ modules/system/system.install 30 Sep 2008 16:59:58 -0000 @@ -3048,7 +3048,17 @@ function system_update_7010() { } /** + * Remove the array_filter variable. + */ +function system_update_7011() { + $ret = array(); + variable_del('array_filter'); + $ret[] = array('success' => TRUE, 'query' => "variable_del('array_filter')"); + + return $ret; +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ - Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.624 diff -u -p -r1.624 system.module --- modules/system/system.module 27 Sep 2008 19:47:43 -0000 1.624 +++ modules/system/system.module 30 Sep 2008 17:00:00 -0000 @@ -1217,9 +1217,6 @@ function system_settings_form_submit($fo variable_del($key); } else { - if (is_array($value) && isset($form_state['values']['array_filter'])) { - $value = array_keys(array_filter($value)); - } variable_set($key, $value); } }