You are here

function comment_upload_comment_form_validate in Comment Upload 6

Submit handler for the preview and attach button.

_state

Parameters

array $form:

2 string references to 'comment_upload_comment_form_validate'
comment_upload_alter_comment_form in ./comment_upload.module
Alter the comment form to support AHAH uploads.
comment_upload_upload_form in ./comment_upload.module
Build the section of the upload_form that holds the attachments table and upload element.

File

./comment_upload.module, line 577
Provides file attachment functionality for comments.

Code

function comment_upload_comment_form_validate($form, &$form_state) {
  if (empty($form_state['values']['op']) && (isset($form_state['clicked_button']) && $form_state['clicked_button']['#value'] != t('Attach'))) {
    return;
  }
  elseif (!empty($form_state['rebuild'])) {
    return;
  }
  comment_upload_process_files($form, $form_state);
  foreach ($form['#comment_upload_storage'] as $fid => $file) {
    if (is_numeric($fid)) {
      $form['#comment_upload_storage'][$fid]['description'] = $form_state['values']['files'][$fid]['description'];
      $form['#comment_upload_storage'][$fid]['list'] = $form_state['values']['files'][$fid]['list'];
      $form['#comment_upload_storage'][$fid]['remove'] = $form_state['values']['files'][$fid]['remove'];
      $form['#comment_upload_storage'][$fid]['weight'] = $form_state['values']['files'][$fid]['weight'];
      $form_state['storage']['comment_upload_storage'][$fid] = $form['#comment_upload_storage'][$fid];
    }
  }
  if (isset($form_state['values']['op']) && $form_state['values']['op'] == t('Preview') || isset($form_state['clicked_button']) && $form_state['clicked_button']['#value'] == t('Attach')) {
    $form_state['rebuild'] = TRUE;
  }
  elseif (!empty($form_state['submitted'])) {
    unset($form_state['storage']);
  }
  return;
}