You are here

function node_field_file_widget in Node Field 7.2

Widget for file field.

1 string reference to 'node_field_file_widget'
node_field_file_node_field_info_alter in modules/node_field_file/node_field_file.module
Implements hook_node_field_info_alter().

File

modules/node_field_file/includes/node_field_file.field.inc, line 11
Field related functions for node_field_file module.

Code

function node_field_file_widget($node_field) {
  $extensions = empty($node_field['settings']['file_extensions']) ? 'txt' : $node_field['settings']['file_extensions'];
  $form = array(
    '#type' => 'managed_file',
    '#title' => !empty($node_field['title']) ? $node_field['title'] : t('File'),
    '#default_value' => $node_field['value'],
    '#upload_location' => 'public://',
    '#upload_validators' => array(
      'file_validate_extensions' => array(
        $extensions,
      ),
    ),
  );
  return $form;
}