function autoupload_admin_form in AutoUpload 7
Form builder for the autoupload settings page.
1 string reference to 'autoupload_admin_form'
- autoupload_menu in ./
autoupload.module - Implements hook_menu().
File
- ./
autoupload.admin.inc, line 14 - Contains the administrative functions of the autoupload module.
Code
function autoupload_admin_form($form, $form_state) {
$settings_predefined = variable_get('autoupload_predefined');
$form['predefined'] = array(
'#type' => 'fieldset',
'#title' => t('Predefined File Types'),
'#collapsible' => TRUE,
);
$form['predefined']['desc'] = array(
'#markup' => t('Choose the type(s) of file fields where you would like to use Auto Upload.'),
);
$form['predefined']['managed_file'] = array(
'#type' => 'checkbox',
'#title' => t('Managed'),
'#description' => t('Drupal core managed file fields.'),
'#default_value' => $settings_predefined['managed_file'],
);
$media_disabled = module_exists('media') ? FALSE : TRUE;
$form['predefined']['media'] = array(
'#type' => 'checkbox',
'#title' => t('Media'),
'#description' => t('Auto upload files using the Media module media file selector.'),
'#disabled' => $media_disabled,
'#default_value' => $media_disabled ? 0 : $settings_predefined['media'],
);
$form['predefined']['media_library'] = array(
'#type' => 'checkbox',
'#title' => t('Media Library'),
'#description' => t('Auto select media files from the media library.'),
'#disabled' => $media_disabled,
'#default_value' => $media_disabled ? 0 : $settings_predefined['media_library'],
);
$form['custom'] = array(
'#type' => 'fieldset',
'#title' => t('Custom File Types'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['custom']['desc'] = array(
'#markup' => t('Enter your own custom configurations for fields you would like to use Auto Upload. All selectors should be relative to the context (container) element.'),
);
$form['custom']['custom_type'] = array(
'#type' => 'container',
'#attributes' => array(
'id' => 'autoupload-custom-wrapper',
),
'#tree' => TRUE,
'#theme' => 'autoupload_custom',
);
$settings_userdefined = variable_get('autoupload_userdefined');
// Get count of how many custom types there are.
$count = isset($form_state['custom_count']) ? $form_state['custom_count'] : count($settings_userdefined);
$index = 0;
foreach ((array) $settings_userdefined as $key => $value) {
$form['custom']['custom_type'][$index] = autoupload_custom_combo($index, TRUE, $key, $value);
$index++;
}
$settings_userdefined_disabled = variable_get('autoupload_userdefined_disabled');
$count += count($settings_userdefined_disabled);
foreach ((array) $settings_userdefined_disabled as $key => $value) {
$form['custom']['custom_type'][$index] = autoupload_custom_combo($index, FALSE, $key, $value);
$index++;
}
$count++;
for ($index; $index < $count; $index++) {
$form['custom']['custom_type'][$index] = autoupload_custom_combo($index);
}
$form['custom']['custom_more'] = array(
'#type' => 'submit',
'#value' => t('Add another'),
'#description' => t('Click to add more custom configurations.'),
'#weight' => 2,
'#submit' => array(
'autoupload_custom_more_submit',
),
'#ajax' => array(
'callback' => 'autoupload_custom_ajax',
'wrapper' => 'autoupload-custom-wrapper',
'method' => 'replace',
'effect' => 'none',
),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
return $form;
}