Skip to content
Snippets Groups Projects
Commit 4b687afc authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #932502 by yched, jgraham, grendzy: changing allowed values in 'List' fields.

parent 85fc9401
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -20,7 +20,7 @@ function list_field_schema($field) { ...@@ -20,7 +20,7 @@ function list_field_schema($field) {
), ),
); );
break; break;
case 'list_number': case 'list_float':
$columns = array( $columns = array(
'value' => array( 'value' => array(
'type' => 'float', 'type' => 'float',
...@@ -28,7 +28,8 @@ function list_field_schema($field) { ...@@ -28,7 +28,8 @@ function list_field_schema($field) {
), ),
); );
break; break;
default: case 'list_integer':
case 'list_boolean':
$columns = array( $columns = array(
'value' => array( 'value' => array(
'type' => 'int', 'type' => 'int',
...@@ -43,4 +44,75 @@ function list_field_schema($field) { ...@@ -43,4 +44,75 @@ function list_field_schema($field) {
'value' => array('value'), 'value' => array('value'),
), ),
); );
} }
\ No newline at end of file
/**
* Rename the list field types and change 'allowed_values' format.
*/
function list_update_7001() {
$fields = _update_7000_field_read_fields(array('module' => 'list'));
foreach ($fields as $field_name => $field) {
$update = array();
// Translate the old string format into the new array format.
$allowed_values = $field['settings']['allowed_values'];
if (is_string($allowed_values)) {
$position_keys = ($field['type'] == 'list');
$allowed_values = _list_update_7001_extract_allowed_values($allowed_values, $position_keys);
// Additionally, float keys need to be disambiguated ('.5' is '0.5').
if ($field['type'] == 'list_number') {
$keys = array_map(create_function('$a', 'return (string) (float) $a;'), array_keys($allowed_values));
$allowed_values = array_combine($keys, array_values($allowed_values));
}
// Place the new setting in the existing serialized 'data' column.
$data = db_query("SELECT data FROM {field_config} WHERE id = :id", array(':id' => $field['id']))->fetchField();
$data = unserialize($data);
$data['settings']['allowed_values'] = $allowed_values;
$update['data'] = serialize($data);
}
// Rename field types.
$types = array('list' => 'list_integer', 'list_number' => 'list_float');
if (isset($types[$field['type']])) {
$update['type'] = $types[$field['type']];
}
// Save the new data.
if ($update) {
$query = db_update('field_config')
->condition('id', $field['id'])
->fields($update)
->execute();
}
}
}
/**
* Helper function for list_update_7001: extract allowed values from a string.
*
* This reproduces the parsing logic in use before D7 RC2.
*/
function _list_update_7001_extract_allowed_values($string, $position_keys) {
$values = array();
$list = explode("\n", $string);
$list = array_map('trim', $list);
$list = array_filter($list, 'strlen');
foreach ($list as $key => $value) {
// Check for a manually specified key.
if (strpos($value, '|') !== FALSE) {
list($key, $value) = explode('|', $value);
}
// Otherwise see if we need to use the value as the key. The "list" type
// will automatically convert non-keyed lines to integers.
elseif (!$position_keys) {
$key = $value;
}
$values[$key] = (isset($value) && $value !== '') ? $value : $key;
}
return $values;
}
This diff is collapsed.
...@@ -24,10 +24,10 @@ class ListFieldTestCase extends FieldTestCase { ...@@ -24,10 +24,10 @@ class ListFieldTestCase extends FieldTestCase {
$this->field_name = 'test_list'; $this->field_name = 'test_list';
$this->field = array( $this->field = array(
'field_name' => $this->field_name, 'field_name' => $this->field_name,
'type' => 'list', 'type' => 'list_integer',
'cardinality' => 1, 'cardinality' => 1,
'settings' => array( 'settings' => array(
'allowed_values' => "1|One\n2|Two\n3|Three\n", 'allowed_values' => array(1 => 'One', 2 => 'Two', 3 => 'Three'),
), ),
); );
$this->field = field_create_field($this->field); $this->field = field_create_field($this->field);
...@@ -57,7 +57,7 @@ class ListFieldTestCase extends FieldTestCase { ...@@ -57,7 +57,7 @@ class ListFieldTestCase extends FieldTestCase {
$this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 exists')); $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 exists'));
// Removed options do not appear. // Removed options do not appear.
$this->field['settings']['allowed_values'] = "2|Two"; $this->field['settings']['allowed_values'] = array(2 => 'Two');
field_update_field($this->field); field_update_field($this->field);
$entity = field_test_create_stub_entity(); $entity = field_test_create_stub_entity();
$form = drupal_get_form('field_test_entity_form', $entity); $form = drupal_get_form('field_test_entity_form', $entity);
...@@ -66,7 +66,7 @@ class ListFieldTestCase extends FieldTestCase { ...@@ -66,7 +66,7 @@ class ListFieldTestCase extends FieldTestCase {
$this->assertTrue(empty($form[$this->field_name][$langcode][3]), t('Option 3 does not exist')); $this->assertTrue(empty($form[$this->field_name][$langcode][3]), t('Option 3 does not exist'));
// Completely new options appear. // Completely new options appear.
$this->field['settings']['allowed_values'] = "10|Update\n20|Twenty"; $this->field['settings']['allowed_values'] = array(10 => 'Update', 20 => 'Twenty');
field_update_field($this->field); field_update_field($this->field);
$form = drupal_get_form('field_test_entity_form', $entity); $form = drupal_get_form('field_test_entity_form', $entity);
$this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist')); $this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist'));
...@@ -78,7 +78,7 @@ class ListFieldTestCase extends FieldTestCase { ...@@ -78,7 +78,7 @@ class ListFieldTestCase extends FieldTestCase {
// Options are reset when a new field with the same name is created. // Options are reset when a new field with the same name is created.
field_delete_field($this->field_name); field_delete_field($this->field_name);
unset($this->field['id']); unset($this->field['id']);
$this->field['settings']['allowed_values'] = "1|One\n2|Two\n3|Three\n"; $this->field['settings']['allowed_values'] = array(1 => 'One', 2 => 'Two', 3 => 'Three');
$this->field = field_create_field($this->field); $this->field = field_create_field($this->field);
$this->instance = array( $this->instance = array(
'field_name' => $this->field_name, 'field_name' => $this->field_name,
...@@ -122,84 +122,237 @@ class ListFieldUITestCase extends FieldTestCase { ...@@ -122,84 +122,237 @@ class ListFieldUITestCase extends FieldTestCase {
$this->type = $type->type; $this->type = $type->type;
// Store a valid URL name, with hyphens instead of underscores. // Store a valid URL name, with hyphens instead of underscores.
$this->hyphen_type = str_replace('_', '-', $this->type); $this->hyphen_type = str_replace('_', '-', $this->type);
}
/**
* List (integer) : test 'allowed values' input.
*/
function testListAllowedValuesInteger() {
$this->field_name = 'field_list_integer';
$this->createListField('list_integer');
// Flat list of textual values.
$string = "Zero\nOne";
$array = array('0' => 'Zero', '1' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are accepted.'));
// Explicit integer keys.
$string = "0|Zero\n2|Two";
$array = array('0' => 'Zero', '2' => 'Two');
$this->assertAllowedValuesInput($string, $array, t('Integer keys are accepted.'));
// Check that values can be added and removed.
$string = "0|Zero\n1|One";
$array = array('0' => 'Zero', '1' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Values can be added and removed.'));
// Non-integer keys.
$this->assertAllowedValuesInput("1.1|One", 'keys must be integers', t('Non integer keys are rejected.'));
$this->assertAllowedValuesInput("abc|abc", 'keys must be integers', t('Non integer keys are rejected.'));
// Mixed list of keyed and unkeyed values.
$this->assertAllowedValuesInput("Zero\n1|One", 'invalid input', t('Mixed lists are rejected.'));
// Create a node with actual data for the field.
$settings = array(
'type' => $this->type,
$this->field_name => array(LANGUAGE_NONE => array(array('value' => 1))),
);
$node = $this->drupalCreateNode($settings);
// Check that a flat list of values is rejected once the field has data.
$this->assertAllowedValuesInput( "Zero\nOne", 'invalid input', t('Unkeyed lists are rejected once the field has data.'));
// Check that values can be added but values in use cannot be removed.
$string = "0|Zero\n1|One\n2|Two";
$array = array('0' => 'Zero', '1' => 'One', '2' => 'Two');
$this->assertAllowedValuesInput($string, $array, t('Values can be added.'));
$string = "0|Zero\n1|One";
$array = array('0' => 'Zero', '1' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.'));
$this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', t('Values in use cannot be removed.'));
// Delete the node, remove the value.
node_delete($node->nid);
$string = "0|Zero";
$array = array('0' => 'Zero');
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.'));
}
/**
* List (float) : test 'allowed values' input.
*/
function testListAllowedValuesFloat() {
$this->field_name = 'field_list_float';
$this->createListField('list_float');
// Flat list of textual values.
$string = "Zero\nOne";
$array = array('0' => 'Zero', '1' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are accepted.'));
// Explicit numeric keys.
$string = "0|Zero\n.5|Point five";
$array = array('0' => 'Zero', '0.5' => 'Point five');
$this->assertAllowedValuesInput($string, $array, t('Integer keys are accepted.'));
// Check that values can be added and removed.
$string = "0|Zero\n.5|Point five\n1.0|One";
$array = array('0' => 'Zero', '0.5' => 'Point five', '1' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Values can be added and removed.'));
// Non-numeric keys.
$this->assertAllowedValuesInput("abc|abc\n", 'each key must be a valid integer or decimal', t('Non numeric keys are rejected.'));
// Mixed list of keyed and unkeyed values.
$this->assertAllowedValuesInput("Zero\n1|One\n", 'invalid input', t('Mixed lists are rejected.'));
// Create a node with actual data for the field.
$settings = array(
'type' => $this->type,
$this->field_name => array(LANGUAGE_NONE => array(array('value' => .5))),
);
$node = $this->drupalCreateNode($settings);
// Check that a flat list of values is rejected once the field has data.
$this->assertAllowedValuesInput("Zero\nOne", 'invalid input', t('Unkeyed lists are rejected once the field has data.'));
// Check that values can be added but values in use cannot be removed.
$string = "0|Zero\n.5|Point five\n2|Two";
$array = array('0' => 'Zero', '0.5' => 'Point five', '2' => 'Two');
$this->assertAllowedValuesInput($string, $array, t('Values can be added.'));
$string = "0|Zero\n.5|Point five";
$array = array('0' => 'Zero', '0.5' => 'Point five');
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.'));
$this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', t('Values in use cannot be removed.'));
// Create random field name. // Delete the node, remove the value.
$this->field_label = $this->randomString(); node_delete($node->nid);
$this->field_name = strtolower($this->randomName()); $string = "0|Zero";
$array = array('0' => 'Zero');
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.'));
} }
/** /**
* Tests that allowed values are properly validated in the UI. * List (text) : test 'allowed values' input.
*/ */
function testAllowedValues() { function testListAllowedValuesText() {
$element_name = "field[settings][allowed_values]"; $this->field_name = 'field_list_text';
$this->createListField('list_text');
// Test 'List' field type.
$admin_path = $this->createListFieldAndEdit('list'); // Flat list of textual values.
// Check that non-integer keys are rejected. $string = "Zero\nOne";
$edit = array($element_name => "1.1|one\n"); $array = array('Zero' => 'Zero', 'One' => 'One');
$this->drupalPost($admin_path, $edit, t('Save settings')); $this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are accepted.'));
$this->assertText("keys must be integers", t('Form validation failed.')); // Explicit keys.
$string = "zero|Zero\none|One";
// Test 'List (number)' field type. $array = array('zero' => 'Zero', 'one' => 'One');
$admin_path = $this->createListFieldAndEdit('list_number'); $this->assertAllowedValuesInput($string, $array, t('Explicit keys are accepted.'));
// Check that non-numeric keys are rejected. // Check that values can be added and removed.
$edit = array($element_name => "1|one\nB|two"); $string = "zero|Zero\ntwo|Two";
$this->drupalPost($admin_path, $edit, t('Save settings')); $array = array('zero' => 'Zero', 'two' => 'Two');
$this->assertText("each key must be a valid integer or decimal", t('Form validation failed.')); $this->assertAllowedValuesInput($string, $array, t('Values can be added and removed.'));
// Mixed list of keyed and unkeyed values.
// Test 'List (text)' field type. $string = "zero|Zero\nOne\n";
$admin_path = $this->createListFieldAndEdit('list_text'); $array = array('zero' => 'Zero', 'One' => 'One');
// Check that overly long keys are rejected. $this->assertAllowedValuesInput($string, $array, t('Mixed lists are accepted.'));
$edit = array($element_name => "1|one\n" . $this->randomName(256) . "|two"); // Overly long keys.
$this->drupalPost($admin_path, $edit, t('Save settings')); $this->assertAllowedValuesInput("zero|Zero\n" . $this->randomName(256) . "|One", 'each key must be a string at most 255 characters long', t('Overly long keys are rejected.'));
$this->assertText("each key must be a string at most 255 characters long", t('Form validation failed.'));
// Create a node with actual data for the field.
// Test 'Boolean' field type. $settings = array(
$admin_path = $this->createListFieldAndEdit('list_boolean'); 'type' => $this->type,
$this->field_name => array(LANGUAGE_NONE => array(array('value' => 'One'))),
);
$node = $this->drupalCreateNode($settings);
// Check that flat lists of values are still accepted once the field has
// data.
$string = "Zero\nOne";
$array = array('Zero' => 'Zero', 'One' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are still accepted once the field has data.'));
// Check that values can be added but values in use cannot be removed.
$string = "Zero\nOne\nTwo";
$array = array('Zero' => 'Zero', 'One' => 'One', 'Two' => 'Two');
$this->assertAllowedValuesInput($string, $array, t('Values can be added.'));
$string = "Zero\nOne";
$array = array('Zero' => 'Zero', 'One' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.'));
$this->assertAllowedValuesInput("Zero", 'some values are being removed while currently in use', t('Values in use cannot be removed.'));
// Delete the node, remove the value.
node_delete($node->nid);
$string = "Zero";
$array = array('Zero' => 'Zero');
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.'));
}
/**
* List (boolen) : test 'On/Off' values input.
*/
function testListAllowedValuesBoolean() {
$this->field_name = 'field_list_boolean';
$this->createListField('list_boolean');
// Check that the seperate 'On' and 'Off' form fields work. // Check that the seperate 'On' and 'Off' form fields work.
$on = $this->randomName(); $on = $this->randomName();
$off = $this->randomName(); $off = $this->randomName();
$allowed_values = array(1 => $on, 0 => $off);
$edit = array( $edit = array(
'on' => $on, 'on' => $on,
'off' => $off, 'off' => $off,
); );
$this->drupalPost($admin_path, $edit, t('Save settings')); $this->drupalPost($this->admin_path, $edit, t('Save settings'));
$this->assertText("Saved test_list_boolean configuration.", t("The 'On' and 'Off' form fields work for boolean fields.")); $this->assertText("Saved field_list_boolean configuration.", t("The 'On' and 'Off' form fields work for boolean fields."));
// Test the allowed_values on the field settings form. // Test the allowed_values on the field settings form.
$this->drupalGet($admin_path); $this->drupalGet($this->admin_path);
$this->assertFieldByName('on', $on, t("The 'On' value is stored correctly.")); $this->assertFieldByName('on', $on, t("The 'On' value is stored correctly."));
$this->assertFieldByName('off', $off, t("The 'Off' value is stored correctly.")); $this->assertFieldByName('off', $off, t("The 'Off' value is stored correctly."));
$field = field_info_field($this->field['field_name']); $field = field_info_field($this->field_name);
$this->assertEqual($field['settings']['allowed_values'], "0|$off\n1|$on", t('The allowed value is correct')); $this->assertEqual($field['settings']['allowed_values'], $allowed_values, t('The allowed value is correct'));
$this->assertFalse(isset($field['settings']['on']), t('The on value is not saved into settings')); $this->assertFalse(isset($field['settings']['on']), t('The on value is not saved into settings'));
$this->assertFalse(isset($field['settings']['off']), t('The off value is not saved into settings')); $this->assertFalse(isset($field['settings']['off']), t('The off value is not saved into settings'));
} }
/** /**
* Helper function to create list field of a given type and get the edit page. * Helper function to create list field of a given type.
* *
* @param string $type * @param string $type
* 'list', 'list_boolean', 'list_number', or 'list_text' * 'list_integer', 'list_float', 'list_text' or 'list_boolean'
*/ */
protected function createListFieldAndEdit($type) { protected function createListField($type) {
// Create a test field and instance. // Create a test field and instance.
$field_name = 'test_' . $type;
$field = array( $field = array(
'field_name' => $field_name, 'field_name' => $this->field_name,
'type' => $type, 'type' => $type,
); );
field_create_field($field); field_create_field($field);
$this->field = $field;
$instance = array( $instance = array(
'field_name' => $field_name, 'field_name' => $this->field_name,
'entity_type' => 'node', 'entity_type' => 'node',
'bundle' => $this->type, 'bundle' => $this->type,
); );
field_create_instance($instance); field_create_instance($instance);
$admin_path = 'admin/structure/types/manage/' . $this->hyphen_type . '/fields/' . $field_name; $this->admin_path = 'admin/structure/types/manage/' . $this->hyphen_type . '/fields/' . $this->field_name;
return $admin_path;
} }
/**
* Tests a string input for the 'allowed values' form element.
*
* @param $input_string
* The input string, in the pipe-linefeed format expected by the form
* element.
* @param $result
* Either an expected resulting array in
* $field['settings']['allowed_values'], or an expected error message.
* @param $message
* Message to display.
*/
function assertAllowedValuesInput($input_string, $result, $message) {
$edit = array('field[settings][allowed_values]' => $input_string);
$this->drupalPost($this->admin_path, $edit, t('Save settings'));
if (is_string($result)) {
$this->assertText($result, $message);
}
else {
field_info_cache_clear();
$field = field_info_field($this->field_name);
$this->assertIdentical($field['settings']['allowed_values'], $result, $message);
}
}
} }
...@@ -16,11 +16,11 @@ class OptionsWidgetsTestCase extends FieldTestCase { ...@@ -16,11 +16,11 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Field with cardinality 1. // Field with cardinality 1.
$this->card_1 = array( $this->card_1 = array(
'field_name' => 'card_1', 'field_name' => 'card_1',
'type' => 'list', 'type' => 'list_integer',
'cardinality' => 1, 'cardinality' => 1,
'settings' => array( 'settings' => array(
// Make sure that 0 works as an option. // Make sure that 0 works as an option.
'allowed_values' => "0|Zero\n1|One\n2|Some <script>dangerous</script> & unescaped <strong>markup</strong>\n", 'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>'),
), ),
); );
$this->card_1 = field_create_field($this->card_1); $this->card_1 = field_create_field($this->card_1);
...@@ -28,11 +28,11 @@ class OptionsWidgetsTestCase extends FieldTestCase { ...@@ -28,11 +28,11 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Field with cardinality 2. // Field with cardinality 2.
$this->card_2 = array( $this->card_2 = array(
'field_name' => 'card_2', 'field_name' => 'card_2',
'type' => 'list', 'type' => 'list_integer',
'cardinality' => 2, 'cardinality' => 2,
'settings' => array( 'settings' => array(
// Make sure that 0 works as an option. // Make sure that 0 works as an option.
'allowed_values' => "0|Zero\n1|One\n2|Some <script>dangerous</script> & unescaped <strong>markup</strong>\n", 'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>'),
), ),
); );
$this->card_2 = field_create_field($this->card_2); $this->card_2 = field_create_field($this->card_2);
...@@ -44,7 +44,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { ...@@ -44,7 +44,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
'cardinality' => 1, 'cardinality' => 1,
'settings' => array( 'settings' => array(
// Make sure that 0 works as a 'on' value'. // Make sure that 0 works as a 'on' value'.
'allowed_values' => "1|No\n0|Some <script>dangerous</script> & unescaped <strong>markup</strong>\n", 'allowed_values' => array(1 => 'Zero', 0 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>'),
), ),
); );
$this->bool = field_create_field($this->bool); $this->bool = field_create_field($this->bool);
...@@ -100,7 +100,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { ...@@ -100,7 +100,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
$this->assertFieldValues($entity_init, 'card_1', $langcode, array()); $this->assertFieldValues($entity_init, 'card_1', $langcode, array());
// Check that required radios with one option is auto-selected. // Check that required radios with one option is auto-selected.
$this->card_1['settings']['allowed_values'] = '99|Only allowed value'; $this->card_1['settings']['allowed_values'] = array(99 => 'Only allowed value');
field_update_field($this->card_1); field_update_field($this->card_1);
$instance['required'] = TRUE; $instance['required'] = TRUE;
field_update_instance($instance); field_update_instance($instance);
...@@ -187,7 +187,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { ...@@ -187,7 +187,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
$this->assertFieldValues($entity_init, 'card_2', $langcode, array()); $this->assertFieldValues($entity_init, 'card_2', $langcode, array());
// Required checkbox with one option is auto-selected. // Required checkbox with one option is auto-selected.
$this->card_2['settings']['allowed_values'] = '99|Only allowed value'; $this->card_2['settings']['allowed_values'] = array(99 => 'Only allowed value');
field_update_field($this->card_2); field_update_field($this->card_2);
$instance['required'] = TRUE; $instance['required'] = TRUE;
field_update_instance($instance); field_update_instance($instance);
...@@ -263,7 +263,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { ...@@ -263,7 +263,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Test optgroups. // Test optgroups.
$this->card_1['settings']['allowed_values'] = NULL; $this->card_1['settings']['allowed_values'] = array();
$this->card_1['settings']['allowed_values_function'] = 'list_test_allowed_values_callback'; $this->card_1['settings']['allowed_values_function'] = 'list_test_allowed_values_callback';
field_update_field($this->card_1); field_update_field($this->card_1);
...@@ -378,7 +378,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { ...@@ -378,7 +378,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Test optgroups. // Test optgroups.
// Use a callback function defining optgroups. // Use a callback function defining optgroups.
$this->card_2['settings']['allowed_values'] = NULL; $this->card_2['settings']['allowed_values'] = array();
$this->card_2['settings']['allowed_values_function'] = 'list_test_allowed_values_callback'; $this->card_2['settings']['allowed_values_function'] = 'list_test_allowed_values_callback';
field_update_field($this->card_2); field_update_field($this->card_2);
$instance['required'] = FALSE; $instance['required'] = FALSE;
...@@ -460,7 +460,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { ...@@ -460,7 +460,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Create a test field instance. // Create a test field instance.
$fieldUpdate = $this->bool; $fieldUpdate = $this->bool;
$fieldUpdate['settings']['allowed_values'] = "0|0\n1|MyOnValue"; $fieldUpdate['settings']['allowed_values'] = array(0 => 0, 1 => 'MyOnValue');
field_update_field($fieldUpdate); field_update_field($fieldUpdate);
$instance = array( $instance = array(
'field_name' => $this->bool['field_name'], 'field_name' => $this->bool['field_name'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment