Commit 3dd0e821 authored by Ruslan Kabalin's avatar Ruslan Kabalin
Browse files

pieforms: new filesize parameter in file-related elements



If filesize is set in pieform, a hidden element MAX_FILE_SIZE with
specified size will be added prior to the file element.
Signed-off-by: default avatarRuslan Kabalin <ruslan.kabalin@luns.net.uk>
parent 79e4e6bc
......@@ -48,6 +48,10 @@ function pieform_element_files(Pieform $form, $element) {
$smarty->assign('name', $form->get_name() . '_' . $element['name']);
if (isset($element['maxfilesize']) && is_int($element['maxfilesize'])){
$smarty->assign('maxfilesize', $element['maxfilesize']);
}
return $smarty->fetch('form/files.tpl');
}
......
......@@ -32,8 +32,12 @@
* @return string The HTML for the element
*/
function pieform_element_file(Pieform $form, $element) {/*{{{*/
return '<input type="file"'
. $form->element_attributes($element) . '>';
$result = '';
if (isset($element['maxfilesize']) && is_int($element['maxfilesize'])){
$result = '<input type="hidden" name="MAX_FILE_SIZE" value="' . $maxfilesize . '"/>';
}
$result .= '<input type="file"' . $form->element_attributes($element) . '>';
return $result;
}/*}}}*/
function pieform_element_file_get_value(Pieform $form, $element) {/*{{{*/
......
......@@ -14,6 +14,9 @@
}
</script>
<div id="{{$name}}_list">
{{if $maxfilesize}}
<input type="hidden" name="MAX_FILE_SIZE" value="{{$maxfilesize}}"/>
{{/if}}
<input type="file" name="{{$name}}_files_0"/>
</div>
<a href="" onclick="{{$name}}_new(); return false;">[+]</a>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment