You are here

function _webform_edit_file_filtering_validate in Webform 6.2

Same name and namespace in other branches
  1. 5.2 components/file.inc \_webform_edit_file_filtering_validate()

Change the submitted values of the component so that all filtering extensions are saved as a single array.

1 string reference to '_webform_edit_file_filtering_validate'
_webform_edit_file in components/file.inc
Create a set of form items to be displayed on the form for editing this component. Use care naming the form items, as this correlates directly to the database schema. The component "Name" and "Description" fields are added to every…

File

components/file.inc, line 152
Webform module file component.

Code

function _webform_edit_file_filtering_validate($form_element, &$form_state) {

  // Predefined types.
  $extensions = array();
  foreach (element_children($form_element['types']) as $category) {
    foreach (array_keys($form_element['types'][$category]['#value']) as $extension) {
      if ($form_element['types'][$category][$extension]['#value']) {
        $extensions[] = $extension;
      }
    }
  }

  // Additional types.
  $additional_extensions = explode(',', $form_element['addextensions']['#value']);
  foreach ($additional_extensions as $extension) {
    $clean_extension = drupal_strtolower(trim($extension));
    if (!empty($clean_extension) && !in_array($clean_extension, $extensions)) {
      $extensions[] = $clean_extension;
    }
  }
  form_set_value($form_element['types'], $extensions, $form_state);
}