Skip to content

Commit

Permalink
Issue #1066274 by pcambra, Damien Tournoud, xjm: Added hook_options_l…
Browse files Browse the repository at this point in the history
…ist() should allow to pass the instance of a field .
  • Loading branch information
webchick committed Oct 20, 2011
1 parent 629a4de commit a5fd8c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion modules/field/modules/options/options.api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion modules/field/modules/options/options.module
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a5fd8c9

Please sign in to comment.