summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Petsovits2007-06-22 14:45:32 (GMT)
committer Jakob Petsovits2007-06-22 14:45:32 (GMT)
commitba0bcaa529a27457448bbd7c75d399f833a1a4ae (patch)
tree8f71eb9293179d1d6381eb5abf733abe5a758e41
parent3382c3c35be21d6e2224fedb7df3103809787b27 (diff)
#146327 by myself: Add an option to hide the "List" checkbox.
-rw-r--r--filefield.module22
1 files changed, 19 insertions, 3 deletions
diff --git a/filefield.module b/filefield.module
index 211b90a..87cf637 100644
--- a/filefield.module
+++ b/filefield.module
@@ -268,11 +268,17 @@ function filefield_widget_settings($op, $widget) {
if (function_exists('token_replace')) {
$form['file_path']['#description'] .= theme('token_help', 'all');
}
+ $form['show_list'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Show "List" option'),
+ '#default_value' => isset($widget['show_list']) ? $widget['show_list'] : 1,
+ '#description' => t('If enabled, the user can choose for each file whether it should be listed or not. If disabled, the "List" checkbox will be hidden and files are always listed.'),
+ );
return $form;
case 'validate':
break;
case 'save':
- return array('file_extensions', 'file_path');
+ return array('file_extensions', 'file_path', 'show_list');
}
}
@@ -487,6 +493,9 @@ function _filefield_file_form($node, $field, $file) {
'#type' => 'checkbox',
'#default_value' => $file['list'],
);
+ if (isset($field['widget']['show_list']) && !$field['widget']['show_list']) {
+ $form['list']['#type'] = 'value';
+ }
$form['filename'] = array('#type' => 'value', '#value' => $file['filename']);
$form['filepath'] = array('#type' => 'value', '#value' => $file['filepath']);
@@ -573,12 +582,19 @@ function _filefield_file_load($fid = NULL) {
}
function theme_filefield_form_current($form) {
- $header = array(t('Delete'), t('List'), t('Description'), t('Size'));
+ // If the "List" option hasn't been hidden as 'value', show it.
+ $show_list = ($form[0]['list']['#type'] == 'checkbox');
+
+ $header = $show_list
+ ? array(t('Delete'), t('List'), t('Description'), t('Size'))
+ : array(t('Delete'), t('Description'), t('Size'));
foreach (element_children($form) as $key) {
$row = array();
$row[] = drupal_render($form[$key]['delete']);
- $row[] = drupal_render($form[$key]['list']);
+ if ($show_list) {
+ $row[] = drupal_render($form[$key]['list']);
+ }
$row[] = drupal_render($form[$key]['icon']).
drupal_render($form[$key]['description']).
drupal_render($form[$key]['url']);