Drupal - Removing the upload button in managed files
The work to separate out the managed_file
element is done in file_managed_file_process()
, which is the default #process
function for that type of element.
To hide the upload button you need to implement your own simple #process
function for the element:
function MYMODULE_my_form($form, &$form_state) {
$form['image'] = array(
'#type' => 'managed_file',
'#title' => 'File',
'#upload_location' => 'public://my-files/',
'#process' => array('MYMODULE_my_file_element_process')
);
return $form;
}
function MYMODULE_my_file_element_process($element, &$form_state, $form) {
$element = file_managed_file_process($element, $form_state, $form);
$element['upload_button']['#access'] = FALSE;
return $element;
}