Allow modules to alter information about fields that should be prepopulated in log forms.
This commit is contained in:
parent
c27f2ec10f
commit
ffb5a8fd10
|
@ -79,6 +79,27 @@ function hook_farm_log_prepopulate_reference_fields($log_type) {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow modules to alter information about fields that should be
|
||||
* prepopulated in log forms.
|
||||
*
|
||||
* @param array $fields
|
||||
* An array of field information defined via
|
||||
* hook_farm_log_prepopulate_reference_fields().
|
||||
* @param string $log_type
|
||||
* The log type.
|
||||
*
|
||||
* @return array
|
||||
* Returns an array of field information.
|
||||
*/
|
||||
function hook_farm_log_prepopulate_reference_fields_alter(&$fields, $log_type) {
|
||||
|
||||
// Example: don't allow prepopulating the asset field on activity logs.
|
||||
if ($log_type == 'farm_activity') {
|
||||
unset($fields['field_farm_asset']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -369,6 +369,9 @@ function farm_log_prepopulate_log_form_references(&$form) {
|
|||
// this log type.
|
||||
$fields = module_invoke_all('farm_log_prepopulate_reference_fields', $log_type);
|
||||
|
||||
// Allow modules to alter the field information.
|
||||
drupal_alter('farm_log_prepopulate_reference_fields', $fields, $log_type);
|
||||
|
||||
// Populate the fields.
|
||||
foreach ($fields as $field => $info) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue