function atom_reference_field_widget_form_process in Scald: Media Management made easy 7
Process the Atom Reference widget element.
Add either the atom reference representation or the placeholder on the fly, depending on the field being filled.
1 string reference to 'atom_reference_field_widget_form_process'
- atom_reference_field_widget_form in modules/
fields/ atom_reference/ atom_reference.module - Implements hook_field_widget_form.
File
- modules/
fields/ atom_reference/ atom_reference.module, line 386 - Defines a new field type, allowing to directly reference Scald Atoms from a node.
Code
function atom_reference_field_widget_form_process(&$element) {
// Get the default value, rendering context and format the placeholder accordingly.
$preview_context = variable_get('dnd_context_default', 'sdl_editor_representation');
if (isset($element['#preview_context'])) {
$preview_context = $element['#preview_context'];
}
$default = $element['#value'];
if ($default) {
$prefix = '<div class="atom_reference_drop_zone" data-rendering-context="' . $preview_context . '">' . scald_render($default, $preview_context) . '</div>';
}
else {
$placeholder = t('Drop a resource from Scald media library here.');
$prefix = '<div class="atom_reference_drop_zone" data-rendering-context="' . $preview_context . '"><em>' . $placeholder . '</em></div>';
}
$element['#field_prefix'] = $prefix;
if (isset($element['#entity_type']) && module_exists('i18n_field')) {
$instance = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
$translated_label = i18n_field_translate_property($instance, 'label');
$element['#title'] = $translated_label;
}
return $element;
}