|
@@ -1007,7 +1007,7 @@ function tripal_html5_file_process($element, $form_state, $complete_form) {
|
|
);
|
|
);
|
|
$element['html5_file_table'] = array(
|
|
$element['html5_file_table'] = array(
|
|
'#type' => 'item',
|
|
'#type' => 'item',
|
|
- '#title' => $element['#title'],
|
|
|
|
|
|
+ '#title' => $element['#title'] ? $element['#title'] : 'File Upload',
|
|
'#description' => $element['#description'],
|
|
'#description' => $element['#description'],
|
|
'#markup' => theme('table', $table_vars)
|
|
'#markup' => theme('table', $table_vars)
|
|
);
|
|
);
|
|
@@ -1048,17 +1048,37 @@ function tripal_html5_file_process($element, $form_state, $complete_form) {
|
|
return $element;
|
|
return $element;
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
|
|
+ * Implements the validate hook for the html5_file form element.
|
|
*/
|
|
*/
|
|
function tripal_html5_file_validate($element, &$form_state) {
|
|
function tripal_html5_file_validate($element, &$form_state) {
|
|
$is_required = $element['#required'];
|
|
$is_required = $element['#required'];
|
|
- $fid = $element['#value'];
|
|
|
|
|
|
+ $name = $element['#name'];
|
|
|
|
+ $name = preg_replace('/[^\w]/', '_', $name);
|
|
|
|
+ $fid = $element['#value'][$name];
|
|
|
|
+
|
|
|
|
+ // TODO: the fid should just be the $element['#value'] why isn't this
|
|
|
|
+ // working given the tripal_html5_file_value function below.
|
|
|
|
|
|
if ($is_required and !$fid) {
|
|
if ($is_required and !$fid) {
|
|
- form_error($element, t('A file must be uploaded.'));
|
|
|
|
|
|
+ form_error($element, t('A file must be provided.'));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+/**
|
|
|
|
+ * Implements hook_value() for the html5_file form element.
|
|
|
|
+ */
|
|
|
|
+function tripal_html5_file_value($element, $input = FALSE, &$form_state) {
|
|
|
|
|
|
|
|
+ if ($input) {
|
|
|
|
+ if (is_array($input)) {
|
|
|
|
+ $name = $element['#name'];
|
|
|
|
+ $name = preg_replace('/[^\w]/', '_', $name);
|
|
|
|
+ return $input[$name];
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return $input;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1098,24 +1118,6 @@ function tripal_handle_uploaded_file($filename, $filepath, $type) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-/**
|
|
|
|
- * Implements hook_value() for the html5_file form element.
|
|
|
|
- */
|
|
|
|
-function tripal_html5_file_value($element, $input = FALSE, &$form_state) {
|
|
|
|
-
|
|
|
|
- if ($input) {
|
|
|
|
- if (is_array($input)) {
|
|
|
|
- $name = $element['#name'];
|
|
|
|
- $name = preg_replace('/[^\w]/', '_', $name);
|
|
|
|
- return $input[$name];
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- return $input;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Implements hook_field_display_alter().
|
|
* Implements hook_field_display_alter().
|
|
*
|
|
*
|