function file_module_test_form

7.x file_module_test.module file_module_test_form($form, &$form_state, $tree = TRUE, $extended = FALSE, $default_fid = NULL)

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 drupal/modules/file/tests/file_module_test.module
Implements hook_menu().

File

drupal/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;
}