summaryrefslogtreecommitdiff
path: root/modules/field
diff options
context:
space:
mode:
Diffstat (limited to 'modules/field')
-rw-r--r--modules/field/modules/options/options.module32
-rw-r--r--modules/field/modules/options/options.test11
2 files changed, 4 insertions, 39 deletions
diff --git a/modules/field/modules/options/options.module b/modules/field/modules/options/options.module
index 75683a9fb..e536c08c6 100644
--- a/modules/field/modules/options/options.module
+++ b/modules/field/modules/options/options.module
@@ -152,7 +152,6 @@ function options_field_widget_validate($element, &$form_state) {
*/
function _options_properties($type, $multiple, $required, $has_value) {
$base = array(
- 'zero_placeholder' => FALSE,
'filter_xss' => FALSE,
'strip_tags' => FALSE,
'empty_option' => FALSE,
@@ -190,9 +189,6 @@ function _options_properties($type, $multiple, $required, $has_value) {
case 'buttons':
$properties = array(
'filter_xss' => TRUE,
- // Form API 'checkboxes' do not suport 0 as an option, so we replace it with
- // a placeholder within the form workflow.
- 'zero_placeholder' => $multiple,
);
// Add a 'none' option for non-required radio buttons.
if (!$required && !$multiple) {
@@ -238,18 +234,6 @@ function _options_get_options($field, $instance, $properties) {
* The function is recursive to support optgroups.
*/
function _options_prepare_options(&$options, $properties) {
- // Substitute the '_0' placeholder.
- if ($properties['zero_placeholder']) {
- $values = array_keys($options);
- $labels = array_values($options);
- // Use a strict comparison, because 0 == 'any string'.
- $index = array_search(0, $values, TRUE);
- if ($index !== FALSE && !is_array($options[$index])) {
- $values[$index] = '_0';
- $options = array_combine($values, $labels);
- }
- }
-
foreach ($options as $value => $label) {
// Recurse for optgroups.
if (is_array($label)) {
@@ -273,14 +257,6 @@ function _options_storage_to_form($items, $options, $column, $properties) {
$items_transposed = options_array_transpose($items);
$values = (isset($items_transposed[$column]) && is_array($items_transposed[$column])) ? $items_transposed[$column] : array();
- // Substitute the '_0' placeholder.
- if ($properties['zero_placeholder']) {
- $index = array_search('0', $values);
- if ($index !== FALSE) {
- $values[$index] = '_0';
- }
- }
-
// Discard values that are not in the current list of options. Flatten the
// array if needed.
if ($properties['optgroups']) {
@@ -302,14 +278,6 @@ function _options_form_to_storage($element) {
$values = array($values[0] ? $element['#on_value'] : $element['#off_value']);
}
- // Substitute the '_0' placeholder.
- if ($properties['zero_placeholder']) {
- $index = array_search('_0', $values);
- if ($index !== FALSE) {
- $values[$index] = 0;
- }
- }
-
// Filter out the 'none' option. Use a strict comparison, because
// 0 == 'any string'.
if ($properties['empty_option']) {
diff --git a/modules/field/modules/options/options.test b/modules/field/modules/options/options.test
index cd85e6579..110ab5767 100644
--- a/modules/field/modules/options/options.test
+++ b/modules/field/modules/options/options.test
@@ -112,9 +112,6 @@ class OptionsWidgetsTestCase extends FieldTestCase {
* Tests the 'options_buttons' widget (multiple select).
*/
function testCheckBoxes() {
- // Checkboxes do not support '0' as an option, the widget internally
- // replaces it with '_0'.
-
// Create an instance of the 'multiple values' field.
$instance = array(
'field_name' => $this->card_2['field_name'],
@@ -142,7 +139,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Submit form: select first and third options.
$edit = array(
- "card_2[$langcode][_0]" => TRUE,
+ "card_2[$langcode][0]" => TRUE,
"card_2[$langcode][1]" => FALSE,
"card_2[$langcode][2]" => TRUE,
);
@@ -157,7 +154,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Submit form: select only first option.
$edit = array(
- "card_2[$langcode][_0]" => TRUE,
+ "card_2[$langcode][0]" => TRUE,
"card_2[$langcode][1]" => FALSE,
"card_2[$langcode][2]" => FALSE,
);
@@ -172,7 +169,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Submit form: select the three options while the field accepts only 2.
$edit = array(
- "card_2[$langcode][_0]" => TRUE,
+ "card_2[$langcode][0]" => TRUE,
"card_2[$langcode][1]" => TRUE,
"card_2[$langcode][2]" => TRUE,
);
@@ -181,7 +178,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Submit form: uncheck all options.
$edit = array(
- "card_2[$langcode][_0]" => FALSE,
+ "card_2[$langcode][0]" => FALSE,
"card_2[$langcode][1]" => FALSE,
"card_2[$langcode][2]" => FALSE,
);