summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-10-19 23:39:43 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2011-10-19 23:39:43 -0700
commita5fd8c9478e0a99c44a256cca6bd0b4cb5bb2ac5 (patch)
tree407e0a1cfd45f90cfed9bd5ef190347de8b4686d /modules
parent629a4dea2fad9f4a5fcb7c68866b25b4077f7ce5 (diff)
downloadbrdo-a5fd8c9478e0a99c44a256cca6bd0b4cb5bb2ac5.tar.gz
brdo-a5fd8c9478e0a99c44a256cca6bd0b4cb5bb2ac5.tar.bz2
Issue #1066274 by pcambra, Damien Tournoud, xjm: Added hook_options_list() should allow to pass the instance of a field .
Diffstat (limited to 'modules')
-rw-r--r--modules/field/modules/options/options.api.php7
-rw-r--r--modules/field/modules/options/options.module2
2 files changed, 7 insertions, 2 deletions
diff --git a/modules/field/modules/options/options.api.php b/modules/field/modules/options/options.api.php
index dfbb631c6..68374446e 100644
--- a/modules/field/modules/options/options.api.php
+++ b/modules/field/modules/options/options.api.php
@@ -15,6 +15,11 @@
*
* @param $field
* The field definition.
+ * @param $instance
+ * (optional) The instance definition. The hook might be called without an
+ * $instance parameter in contexts where no specific instance can be targeted.
+ * 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 +30,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 = NULL) {
// Sample structure.
$options = array(
0 => t('Zero'),
diff --git a/modules/field/modules/options/options.module b/modules/field/modules/options/options.module
index 385f3f47f..d4d05eca2 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);