You are here

function filefield_source_reference_process in FileField Sources 6

Same name and namespace in other branches
  1. 7 sources/reference.inc \filefield_source_reference_process()

A #process callback to extend the filefield_widget element type.

1 string reference to 'filefield_source_reference_process'
filefield_source_reference_info in sources/reference.inc
Implements hook_filefield_source_info().

File

sources/reference.inc, line 97
A FileField extension to allow referencing of existing files.

Code

function filefield_source_reference_process($element, $edit, &$form_state, $form) {
  $element['filefield_reference'] = array(
    '#weight' => 100.5,
    '#theme' => 'filefield_source_reference_element',
    '#filefield_source' => TRUE,
    // Required for proper theming.
    '#filefield_sources_hint_text' => FILEFIELD_SOURCE_REFERENCE_HINT_TEXT,
  );
  $element['filefield_reference']['autocomplete'] = array(
    '#type' => 'textfield',
    '#autocomplete_path' => 'filefield/reference/' . $element['#type_name'] . '/' . $element['#field_name'],
    '#description' => filefield_sources_element_validation_help($element['#upload_validators']),
  );
  $element['filefield_reference']['select'] = array(
    '#name' => implode('_', $element['#array_parents']) . '_autocomplete_select',
    '#type' => 'submit',
    '#value' => t('Select'),
    '#validate' => array(),
    '#submit' => array(
      'node_form_submit_build_node',
    ),
    '#name' => $element['#name'] . '[filefield_reference][button]',
    '#ahah' => array(
      'path' => 'filefield/ahah/' . $element['#type_name'] . '/' . $element['#field_name'] . '/' . $element['#delta'],
      'wrapper' => $element['#id'] . '-ahah-wrapper',
      'method' => 'replace',
      'effect' => 'fade',
    ),
  );
  return $element;
}