summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcatch2011-10-19 11:10:40 (GMT)
committer catch2011-10-19 11:10:40 (GMT)
commit2bf42797f04a02cc4855e6f087c74ae9d2ff11bd (patch)
treefd91053a0122ea2be64075fc5c8f9a04b3d0c82b
parentf15394b0d5042bfa5239f137d08c41034ddf8776 (diff)
Issue #1066274 by pcambra, Damien Tournoud, xjm: Added hook_options_list() should allow to pass the instance of a field.
-rw-r--r--modules/field/modules/list/list.module2
-rw-r--r--modules/field/modules/options/options.api.php6
-rw-r--r--modules/field/modules/options/options.module2
-rw-r--r--modules/taxonomy/taxonomy.module2
4 files changed, 8 insertions, 4 deletions
diff --git a/modules/field/modules/list/list.module b/modules/field/modules/list/list.module
index 1d72be4..6523551 100644
--- a/modules/field/modules/list/list.module
+++ b/modules/field/modules/list/list.module
@@ -419,7 +419,7 @@ function list_field_widget_info_alter(&$info) {
/**
* Implements hook_options_list().
*/
-function list_options_list($field) {
+function list_options_list($field, $instance) {
return list_allowed_values($field);
}
diff --git a/modules/field/modules/options/options.api.php b/modules/field/modules/options/options.api.php
index dfbb631..d1ac0db 100644
--- a/modules/field/modules/options/options.api.php
+++ b/modules/field/modules/options/options.api.php
@@ -15,6 +15,10 @@
*
* @param $field
* The field definition.
+ * @param $instance
+ * The instance definition. It is recommended to only use instance level
+ * properties to filter out values from a list defined by field level
+ * properties.
*
* @return
* The array of options for the field. Array keys are the values to be
@@ -25,7 +29,7 @@
* widget. The HTML tags defined in _field_filter_xss_allowed_tags() are
* allowed, other tags will be filtered.
*/
-function hook_options_list($field) {
+function hook_options_list($field, $instance) {
// Sample structure.
$options = array(
0 => t('Zero'),
diff --git a/modules/field/modules/options/options.module b/modules/field/modules/options/options.module
index 385f3f4..d4d05ec 100644
--- a/modules/field/modules/options/options.module
+++ b/modules/field/modules/options/options.module
@@ -231,7 +231,7 @@ function _options_properties($type, $multiple, $required, $has_value) {
*/
function _options_get_options($field, $instance, $properties) {
// Get the list of options.
- $options = (array) module_invoke($field['module'], 'options_list', $field);
+ $options = (array) module_invoke($field['module'], 'options_list', $field, $instance);
// Sanitize the options.
_options_prepare_options($options, $properties);
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 7921b79..21ab127 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -1319,7 +1319,7 @@ function taxonomy_field_widget_info_alter(&$info) {
/**
* Implements hook_options_list().
*/
-function taxonomy_options_list($field) {
+function taxonomy_options_list($field, $instance) {
$function = !empty($field['settings']['options_list_callback']) ? $field['settings']['options_list_callback'] : 'taxonomy_allowed_values';
return $function($field);
}