You are here

function file_module_test_form in Drupal 7

Form constructor for testing a 'managed_file' element.

See also

file_module_test_form_submit()

Related topics

1 string reference to 'file_module_test_form'
file_module_test_menu in modules/file/tests/file_module_test.module
Implements hook_menu().

File

modules/file/tests/file_module_test.module, line 30
Provides File module pages for testing purposes.

Code

function file_module_test_form($form, &$form_state, $tree = TRUE, $extended = FALSE, $default_fid = NULL) {
  $form['#tree'] = (bool) $tree;
  $form['nested']['file'] = array(
    '#type' => 'managed_file',
    '#title' => t('Managed file'),
    '#upload_location' => 'public://test',
    '#progress_message' => t('Please wait...'),
    '#extended' => (bool) $extended,
    '#size' => 13,
  );
  if ($default_fid) {
    $form['nested']['file']['#default_value'] = $extended ? array(
      'fid' => $default_fid,
    ) : $default_fid;
  }
  $form['textfield'] = array(
    '#type' => 'textfield',
    '#title' => t('Type a value and ensure it stays'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}