summaryrefslogtreecommitdiff
path: root/modules/taxonomy
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-22 00:58:55 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-22 00:58:55 +0000
commit34a8a369aa0afb353d95578768903c6a1d5cd06b (patch)
treecd695ff9c71a5c221f9a5ea4603b04fbc5c2b3bd /modules/taxonomy
parentbc23bfaa11d6a8d40bb12812cfa081b9c5d9b672 (diff)
downloadbrdo-34a8a369aa0afb353d95578768903c6a1d5cd06b.tar.gz
brdo-34a8a369aa0afb353d95578768903c6a1d5cd06b.tar.bz2
#367595 by plach, catch, sun, yched, et al: Added support for translatable fields to Field API.
Diffstat (limited to 'modules/taxonomy')
-rw-r--r--modules/taxonomy/taxonomy.module4
-rw-r--r--modules/taxonomy/taxonomy.test20
2 files changed, 14 insertions, 10 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 6294cf131..36459f73b 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -1930,7 +1930,7 @@ function taxonomy_field_schema($field) {
* Possible error codes:
* - 'taxonomy_term_illegal_value': The value is not part of the list of allowed values.
*/
-function taxonomy_field_validate($obj_type, $object, $field, $instance, $items, &$errors) {
+function taxonomy_field_validate($obj_type, $object, $field, $instance, $langcode, $items, &$errors) {
$allowed_values = taxonomy_allowed_values($field);
$widget = field_info_widget_types($instance['widget']['type']);
@@ -2032,7 +2032,7 @@ function taxonomy_allowed_values($field) {
* This preloads all taxonomy terms for multiple loaded objects at once and
* unsets values for invalid terms that do not exist.
*/
-function taxonomy_field_load($obj_type, $objects, $field, $instances, &$items, $age) {
+function taxonomy_field_load($obj_type, $objects, $field, $instances, $langcode, &$items, $age) {
$tids = array();
// Collect every possible term attached to any of the fieldable entities.
diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test
index 3d20928a3..9ca9592d6 100644
--- a/modules/taxonomy/taxonomy.test
+++ b/modules/taxonomy/taxonomy.test
@@ -453,7 +453,8 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
// Post an article.
$edit = array();
$edit['title'] = $this->randomName();
- $edit['body[0][value]'] = $this->randomName();
+ $langcode = FIELD_LANGUAGE_NONE;
+ $edit["body[$langcode][0][value]"] = $this->randomName();
$edit['taxonomy[' . $this->vocabulary->vid . ']'] = $term1->tid;
$this->drupalPost('node/add/article', $edit, t('Save'));
@@ -495,7 +496,8 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
// Insert the terms in a comma separated list. Vocabulary 1 is a
// free-tagging field created by the default profile.
$edit['taxonomy[tags][' . $this->vocabulary->vid . ']'] = implode(', ', $terms);
- $edit['body[0][value]'] = $this->randomName();
+ $langcode = FIELD_LANGUAGE_NONE;
+ $edit["body[$langcode][0][value]"] = $this->randomName();
$this->drupalPost('node/add/article', $edit, t('Save'));
$this->assertRaw(t('@type %title has been created.', array('@type' => t('Article'), '%title' => $edit['title'])), t('The node was created successfully'));
foreach ($terms as $term) {
@@ -763,20 +765,21 @@ class TaxonomyTermFieldTestCase extends TaxonomyWebTestCase {
field_create_instance($this->instance);
// Test valid and invalid values with field_attach_validate().
+ $langcode = FIELD_LANGUAGE_NONE;
$entity = field_test_create_stub_entity(0, 0, FIELD_TEST_BUNDLE);
$term = $this->createTerm($this->vocabulary);
- $entity->{$this->field_name}[0]['value'] = $term->tid;
+ $entity->{$this->field_name}[$langcode][0]['value'] = $term->tid;
field_attach_validate('test_entity', $entity);
try {
- $this->assertTrue($entity->{$this->field_name}[0]['value'] == $term->tid, t('Correct term does not cause validation error'));
+ $this->assertTrue($entity->{$this->field_name}[$langcode][0]['value'] == $term->tid, t('Correct term does not cause validation error'));
}
catch (FieldValidationException $e) {
- $this->assertTrue($entity->{$this->field_name}[0]['value'] != $term->tid, t('Term from wrong vocabulary does not cause validation error'));
+ $this->assertTrue($entity->{$this->field_name}[$langcode][0]['value'] != $term->tid, t('Term from wrong vocabulary does not cause validation error'));
}
$entity = field_test_create_stub_entity(0, 0, FIELD_TEST_BUNDLE);
$bad_term = $this->createTerm($this->createVocabulary());
- $entity->{$this->field_name}[0]['value'] = $bad_term->tid;
+ $entity->{$this->field_name}[$langcode][0]['value'] = $bad_term->tid;
try {
field_attach_validate('test_entity', $entity);
}
@@ -819,12 +822,13 @@ class TaxonomyTermFieldTestCase extends TaxonomyWebTestCase {
$term = $this->createTerm($this->vocabulary);
// Display creation form.
+ $langcode = FIELD_LANGUAGE_NONE;
$this->drupalGet('test-entity/add/test-bundle');
- $this->assertFieldByName($this->field_name . '[value]', '', t('Widget is displayed'));
+ $this->assertFieldByName("{$this->field_name}[$langcode][value]", '', t('Widget is displayed'));
// Submit with some value.
$edit = array(
- $this->field_name . '[value]' => array($term->tid),
+ "{$this->field_name}[$langcode][value]" => array($term->tid),
);
$this->drupalPost(NULL, $edit, t('Save'));
preg_match('|test-entity/(\d+)/edit|', $this->url, $match);