You are here

function mee_form_alter in Scald: Media Management made easy 7

Implements hook_form_alter().

Normally this should go in a hook_field_instance_settings_form() if the field belongs to the module. But it is not the case, so we implement in a form alter.

File

modules/fields/mee/mee.module, line 222
Defines a special textarea, with drag and drop media driven by Scald and dnd.module.

Code

function mee_form_alter(&$form, &$form_state, $form_id) {

  // Verify if we are in the instance settings form.
  if ($form_id !== 'field_ui_field_edit_form' || !in_array($form['#field']['type'], mee_field_types())) {
    return;
  }
  $settings = $form['#instance']['settings'];
  $context_options = array();
  foreach (scald_contexts_public() as $name => $context) {
    $context_options[$name] = $context['title'];
  }
  $form['instance']['settings']['dnd_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Drag\'n\'Drop Enabled'),
    '#description' => t('Enable DnD for this field will show the Atom library and will allow you to drag and drop atoms to this field.'),
    '#default_value' => $settings['dnd_enabled'],
  );
  $form['instance']['settings']['mee_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('MEE Enabled'),
    '#description' => t('Enable MEE for this field to get access to an advance resource management interface. MEE will automatically detect the resources embedded in this field, and allow you to define a few metadata properties on them, e.g. choose if the node should be unpublished if at some point in the future the resource became unavailable.'),
    '#default_value' => $settings['mee_enabled'],
  );
  $form['instance']['settings']['context_default'] = array(
    '#type' => 'select',
    '#title' => t('Scald default context'),
    '#description' => t('You can customize field level default context for drag and drop atoms.'),
    '#default_value' => isset($settings['context_default']) ? $settings['context_default'] : variable_get('dnd_context_default', 'sdl_editor_representation'),
    '#options' => $context_options,
  );
  $form['instance']['settings']['context'] = array(
    '#type' => 'select',
    '#title' => t('Scald fallback context'),
    '#description' => t('The fallback context is only used when the specified context for embedded atom is not available (e.g. deleted).'),
    '#default_value' => $settings['context'],
    '#options' => $context_options,
  );
}