function regcode_get_field_key in Registration codes 5.3
Get the key of a given field name (redundant) or title This function is quite stupid, but is necessary to compensate a bug in Drupal for correctly retrieving a column key from table sorting querystring-argument "order", which is wrongfully set to the table column's header NAME (=title) instead of FIELD,
which has to be taken into account by searching for the fieldname (array key) by array search by column name
Parameters
$field_key_or_title: The field key (redundant) or title to look up
$fields: Optionally a field/title array to use for lookup
$translated: Whether to compare translated field titles
Return value
An array list of code data arrays
1 call to regcode_get_field_key()
- regcode_admin_list in ./
regcode_admin.inc.php - Return the code list page content with(in) the according filter form
File
- ./
regcode_api.inc.php, line 279 - regcode_api.inc.php contains general low-level functions for the registration-code module, for tasks like
Code
function regcode_get_field_key($field_key_or_title, $fields = NULL, $translated = TRUE) {
if ($fields == NULL) {
$fields = regcode_get_fields($include_related = TRUE);
}
// if argument found as field array key, return it
if (isset($fields['field_key_or_title'])) {
return $field_key_or_title;
}
// else, look for first matching (opt. localized) field array title matching the argument, and return its key
foreach ($fields as $key => $title) {
if ($translated) {
$title = t($title);
}
if ($field_key_or_title == $title) {
return $key;
}
}
}