function filefield_filefield_paths_form_alter in File (Field) Paths 5
Same name and namespace in other branches
- 6 modules/filefield.inc \filefield_filefield_paths_form_alter()
Implementation of hook_filefield_paths_form_alter().
File
- modules/
filefield.inc, line 11 - Provides FileField Paths integration with the FileField module.
Code
function filefield_filefield_paths_form_alter(&$form, &$ffp) {
if (isset($form['module']['#value']) && preg_match('/\\bfilefield\\b|\\bimagefield\\b/', $form['module']['#value'])) {
$ffp[$form['field_name']['#value']] = array(
'show' => TRUE,
'type' => $form['type_name']['#value'],
'form_path' => &$form['widget']['ffp_' . $form['field_name']['#value']],
'file_path_default' => $form['widget']['path_settings']['file_path']['#default_value'],
);
// Create path settings fieldset
$ffp[$form['field_name']['#value']]['form_path'] = array(
'#type' => 'fieldset',
'#title' => t('FileField Path settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$filepath = $form['module']['#value'] == 'filefield' ? 'file_path' : 'image_path';
$form['widget'][$filepath]['#description'] = t('Optional subdirectory within the "%dir" directory where files will be stored. Do not include trailing slash.', array(
'%dir' => variable_get('file_directory_path', 'files'),
));
if ($filepath == 'image_path') {
unset($form['widget'][$filepath]['#suffix']);
}
// Move file path field into path settings fieldset
$ffp[$form['field_name']['#value']]['form_path'][$filepath] = $form['widget'][$filepath];
$form['widget'][$filepath]['#access'] = FALSE;
$form['widget']['description']['#weight'] = 10;
$ffp[$form['field_name']['#value']]['form_path']['#attributes'] = array(
'id' => 'fieldset-path_settings',
);
}
}