Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/references.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"_config_name": "references.settings",
"potential_references_limit": "25"
}
3 changes: 2 additions & 1 deletion node_reference/node_reference.module
Original file line number Diff line number Diff line change
Expand Up @@ -847,13 +847,14 @@ function _node_reference_options($field, $flat = TRUE) {
* @codingStandardsIgnoreStart
*/
function node_reference_potential_references($field, $options = array()) {
$config = config('references.settings');
// @codingStandardsIgnoreEnd
// Fill in default options.
$options += array(
'string' => '',
'match' => 'contains',
'ids' => array(),
'limit' => 25,
'limit' => $config->get('potential_references_limit'),
);

$results = &backdrop_static(__FUNCTION__, array());
Expand Down
1 change: 1 addition & 0 deletions references.info
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package = Fields
core = 7.x
backdrop = 1.x
type = module
configure = admin/config/content/references
dependencies[] = field
dependencies[] = options
files[] = views/references_handler_relationship.inc
Expand Down
59 changes: 59 additions & 0 deletions references.module
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,62 @@ function references_element_validate_integer_positive($element, &$form_state) {
form_error($element, t('%name must be a positive integer.', array('%name' => $element['#title'])));
}
}

/**
* Implements hook_config_info().
*/
function references_config_info() {
return array(
'references.settings' => array(
'label' => t('References settings'),
'group' => t('Configuration'),
),
);
}

/**
* Implements hook_menu().
*/
function references_menu() {
$items['admin/config/content/references'] = array(
'title' => 'References settings',
'description' => 'Configure References.',
'page callback' => 'backdrop_get_form',
'page arguments' => array('references_configuration_form'),
'access arguments' => array('administer references'),
);

return $items;
}


/**
* Implements hook_permission().
*/
function references_permission() {
return array(
'administer references' => array(
'title' => t('Administer References'),
),
);
}

/**
* References configuration form.
*/
function references_configuration_form($form, &$form_state) {
// Form values will be saved to this config file. See system_settings_form().
$form['#config'] = 'references.settings';

// Use $config->get() for default values.
$config = config('references.settings');

$form['potential_references_limit'] = array(
'#type' => 'textfield',
'#title' => t('Potential references limit'),
'#default_value' => $config->get('potential_references_limit'),
'#description' => t('This limit is used in various places (allowed values, autocomplete results, input validation...).'),
);

return system_settings_form($form);
}
3 changes: 2 additions & 1 deletion user_reference/user_reference.module
Original file line number Diff line number Diff line change
Expand Up @@ -841,13 +841,14 @@ function _user_reference_options($field, $flat = TRUE) {
* @codingStandardsIgnoreStart
*/
function user_reference_potential_references($field, $options = array()) {
$config = config('references.settings');
// @codingStandardsIgnoreEnd
// Fill in default options.
$options += array(
'string' => '',
'match' => 'contains',
'ids' => array(),
'limit' => 25,
'limit' => $config->get('potential_references_limit'),
);

$results = &backdrop_static(__FUNCTION__, array());
Expand Down