function file_module_test_form

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

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.