function ml_image_source_selection_form in Media Library 6
Form for our image source selection. Handles both steps of source selection process.
1 string reference to 'ml_image_source_selection_form'
- ml_image_media_forms in ml_image/
ml_image.module - Implementation of hook_media_forms()
File
- ml_image/
ml_image.module, line 162 - Media Library Image module.
Code
function ml_image_source_selection_form(&$form, &$form_state) {
// Check for update and skip step
if ($form_state['action'] == 'update') {
media_library_modal_skip_step($form_state);
}
$sources = ml_image_get_sources();
if (empty($sources)) {
// No sources activated. Snap the admin
drupal_set_message(t('No sources were configured for this media. Please contact the site administrator'), 'error');
// Disable buttons so user won't be able to go ahead
unset($form['buttons']['next']);
unset($form['buttons']['return']);
return;
}
// Proper source selection
foreach ($sources as $source => $info) {
$form[$source] = array(
'#type' => 'fieldset',
'#title' => $info['label'],
);
// Our main radio
$form[$source]['select'] = array(
'#type' => 'radio',
'#return_value' => $source,
'#attributes' => array(
'class' => 'ml-image-source-choice',
),
);
// Get basic form from each source module
$func_name = $info['module'] . '_' . $source . '_source_form';
if (function_exists($func_name)) {
$form[$source][$source] = $func_name($form_state);
}
$form[$source][$source]['#tree'] = TRUE;
}
// We set this so we can be sure that file uploads work in ctools modal.
// See here: http://drupal.org/node/451928
$form['#attributes']['enctype'] = 'multipart/form-data';
$form_state['no buttons'] = TRUE;
}