You are here

function minisite_field_widget_form in Mini site 7

Implements hook_field_widget_form().

File

includes/minisite.field.inc, line 256
Minisite field.

Code

function minisite_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {

  // Add display_field setting to field
  // because file_field_widget_form() assumes it is set.
  $field['settings']['display_field'] = 0;
  $elements = file_field_widget_form($form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
  $settings = $instance['settings'];
  foreach (element_children($elements) as $delta) {

    // Minisite content extensions validation.
    $minisite_extensions = $settings['minisite_extensions'];
    $elements[$delta]['#upload_validators']['_minisite_field_validate_minisite_asset'] = array(
      $minisite_extensions,
    );

    // Add all extra functionality provided by the minisite widget.
    $elements[$delta]['#process'][] = 'minisite_field_widget_process';
  }
  $elements[0]['#description'] = theme('file_upload_help', array(
    'description' => field_filter_xss($instance['description']),
    'upload_validators' => $elements[0]['#upload_validators'],
  ));
  return $elements[0];
}