Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By GizmoRock on
Field file webform not wirk for anonimus
https://www.drupal.org/node/2675170
use patch #2 but not work
This also not work
/**
* Implements hook_element_info_alter().
*/
function example_fixes_element_info_alter(&$type) {
if (isset($type['managed_file'])) {
$type['managed_file'] += ['#process' => []];
array_unshift($type['managed_file']['#process'], 'example_managed_file_webform_process');
}
}
function example_managed_file_webform_process($element, &$form_state, $complete_form) {
// Accept anonymous uploads where Drupal doesn't if file was uploaded in the same session.
if (!empty($form_state['process_input']) && user_is_anonymous()) {
$input = drupal_array_get_nested_value($form_state['input'], $element['#parents']);
if (empty($element['#value']['fid']) && !empty($input['fid']) && isset($_SESSION['webform_files'][$input['fid']])) {
form_set_value($element, $input, $form_state);
$element['#value']['fid'] = $input['fid'];
}
}
return $element;
}