From 19c6b514be3e34b60e644f1a8ef32ff751f57e72 Mon Sep 17 00:00:00 2001 From: megan_w Date: Tue, 2 Oct 2007 11:30:47 +0000 Subject: [PATCH] KTS-2359 "Automatically fill document title from filename" Added an onchange option to the file input. --- plugins/ktcore/folder/addDocument.php | 13 +++++++++++++ templates/ktcore/forms/widgets/file.smarty | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/ktcore/folder/addDocument.php b/plugins/ktcore/folder/addDocument.php index e1bffcf..d9072f5 100644 --- a/plugins/ktcore/folder/addDocument.php +++ b/plugins/ktcore/folder/addDocument.php @@ -86,18 +86,31 @@ class KTFolderAddDocumentAction extends KTFolderAction { $aTypes[] = $oDocumentType; } } + + // Onchange gets the name of the file and inserts it as the document title. + $sFileOnchange = "javascript: + var arrPath=this.value.split('/'); + if(arrPath.length == 1){ + var arrPath=this.value.split('\\\'); + } + var name=arrPath[arrPath.length-1]; + var title=name.split('.'); + document.getElementById('document_name').value=title[0];"; + $oForm->setWidgets(array( array('ktcore.widgets.file',array( 'label' => _kt('File'), 'description' => _kt('The contents of the document to be added to the document management system.'), 'name' => 'file', 'required' => true, + 'onchange' => $sFileOnchange, )), array('ktcore.widgets.string',array( 'label' => _kt('Document Title'), 'description' => sprintf(_kt('The document title is used as the main name of a document throughout %s™.'), APP_NAME), 'name' => 'document_name', 'required' => true, + 'id' => 'document_name', )), array('ktcore.widgets.entityselection',array( 'label' => _kt('Document Type'), diff --git a/templates/ktcore/forms/widgets/file.smarty b/templates/ktcore/forms/widgets/file.smarty index f6afd8c..7443a77 100644 --- a/templates/ktcore/forms/widgets/file.smarty +++ b/templates/ktcore/forms/widgets/file.smarty @@ -1 +1,2 @@ - + -- libgit2 0.21.4