"use form_name (with replaced substitutes) instead of $cell[name], allows to put into the name something like \"app:$cont[id]:files/blah\" or \"app:$row_cont[id]:files/blub\""

This commit is contained in:
Ralf Becker 2009-07-13 08:14:59 +00:00
parent 49c5b2933c
commit 919aea627e

View File

@ -72,6 +72,7 @@ class vfs_widget
*/ */
function pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl) function pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
{ {
//echo "<p>".__METHOD__."($form_name,$value,".array2string($cell).",...)</p>\n";
$type = $cell['type']; $type = $cell['type'];
if ($type != 'vfs-upload') $cell['readonly'] = true; // to not call post-process if ($type != 'vfs-upload') $cell['readonly'] = true; // to not call post-process
@ -89,8 +90,11 @@ class vfs_widget
switch($type) switch($type)
{ {
case 'vfs-upload': // option: allowed mime types (regular expression) if limited case 'vfs-upload': // option: allowed mime types (regular expression) if limited
if(empty($value)) $value = $cell['name']; // if no value via content array, use widget name if (empty($value) && preg_match('/^exec.*\[([^]]+)\]$/',$form_name,$matches)) // if no value via content array, use widget name
{
$value = $matches[1].$matches[2];
}
$extension_data = array('value' => $value, 'mimetype' => $cell['size'], 'type' => $type); $extension_data = array('value' => $value, 'mimetype' => $cell['size'], 'type' => $type);
if ($value[0] != '/') if ($value[0] != '/')
{ {