You are here

function comment_upload_create_file_element in Comment Upload 6

Create the form elements for one file in the attachments table.

Parameters

object $file:

integer $count:

Return value

array

1 call to comment_upload_create_file_element()
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 336
Provides file attachment functionality for comments.

Code

function comment_upload_create_file_element($file, $count) {
  $element = array();
  $description = "<small>" . check_plain(file_create_url($file->filepath)) . "</small>";
  $element['description'] = array(
    '#type' => 'textfield',
    '#default_value' => !empty($file->description) ? $file->description : $file->filename,
    '#maxlength' => 256,
    '#description' => $description,
  );
  $element['size'] = array(
    '#value' => format_size($file->filesize),
  );
  $element['remove'] = array(
    '#type' => 'checkbox',
    '#default_value' => !empty($file->remove),
  );
  $element['list'] = array(
    '#type' => 'checkbox',
    '#default_value' => $file->list,
  );
  $element['weight'] = array(
    '#type' => 'weight',
    '#delta' => $count,
    '#default_value' => $file->weight,
  );
  $element['filename'] = array(
    '#type' => 'value',
    '#value' => $file->filename,
  );
  $element['filepath'] = array(
    '#type' => 'value',
    '#value' => $file->filepath,
  );
  $element['filemime'] = array(
    '#type' => 'value',
    '#value' => $file->filemime,
  );
  $element['filesize'] = array(
    '#type' => 'value',
    '#value' => $file->filesize,
  );
  $element['fid'] = array(
    '#type' => 'value',
    '#value' => $file->fid,
  );
  $element['new'] = array(
    '#type' => 'value',
    '#value' => FALSE,
  );
  return $element;
}