Commit 2bf42797 authored by catch's avatar catch

Issue #1066274 by pcambra, Damien Tournoud, xjm: Added hook_options_list()...

Issue #1066274 by pcambra, Damien Tournoud, xjm: Added hook_options_list() should allow to pass the instance of a field.
parent f15394b0
......@@ -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);
}
......
......@@ -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'),
......
......@@ -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);
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment