You are here

function atom_reference_field_widget_settings_form in Scald: Media Management made easy 7

Implements hook_field_widget_settings_form.

File

modules/fields/atom_reference/atom_reference.module, line 276
Defines a new field type, allowing to directly reference Scald Atoms from a node.

Code

function atom_reference_field_widget_settings_form($field, $instance) {
  $preview_context = isset($instance['widget']['settings']['context']) ? $instance['widget']['settings']['context'] : variable_get('dnd_context_default', 'sdl_editor_representation');
  $form['context'] = array(
    '#type' => 'select',
    '#title' => t('Preview context'),
    '#options' => array(),
    '#default_value' => $preview_context,
    '#description' => t('Scald preview context to be displayed in the edit form.'),
  );
  $contexts = scald_contexts_public();
  foreach ($contexts as $name => $context) {

    // TODO: Atom reference shouldn't need the context to be parsable, there's
    // nothing converting back and forth between the SAS and the rendered
    // representation.
    if (!empty($context['parseable'])) {
      $form['context']['#options'][$name] = $context['title'];
    }
  }
  return $form;
}