1 file.module | file_managed_file_browser_form($form, &$form_state) |
Form to submit a file selected in the file browser.
File
- core/
modules/ file/ file.module, line 1767 - Defines a "managed_file" Form API field and a "file" field for Field module.
Code
function file_managed_file_browser_form($form, &$form_state) {
// FID is set via JavaScript on the client-side. As such, this is a "hidden"
// element, rather than "value". And we use #default_value, not #value, to
// allow client-side changes.
$form['fid'] = array(
'#type' => 'hidden',
'#default_value' => '',
);
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Insert'),
'#validate' => array(),
'#submit' => array(),
'#ajax' => array(
'callback' => 'file_managed_file_browser_submit',
'progress' => array(
'type' => 'throbber',
'message' => NULL,
),
),
);
$form['actions']['cancel'] = array(
'#type' => 'link',
'#title' => t('Cancel'),
'#href' => '',
'#attributes' => array(
// Adding button classes puts the link in the button area of the dialog,
// while the special "dialog-cancel" class closes the dialog.
'class' => array('button', 'button-secondary', 'form-submit', 'dialog-cancel'),
),
);
return $form;
}