Commit 19c6b514be3e34b60e644f1a8ef32ff751f57e72
1 parent
ff37fcbb
KTS-2359
"Automatically fill document title from filename" Added an onchange option to the file input. Committed by: Megan Watson Reviewed by: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7269 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
15 additions
and
1 deletions
plugins/ktcore/folder/addDocument.php
| @@ -86,18 +86,31 @@ class KTFolderAddDocumentAction extends KTFolderAction { | @@ -86,18 +86,31 @@ class KTFolderAddDocumentAction extends KTFolderAction { | ||
| 86 | $aTypes[] = $oDocumentType; | 86 | $aTypes[] = $oDocumentType; |
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| 89 | + | ||
| 90 | + // Onchange gets the name of the file and inserts it as the document title. | ||
| 91 | + $sFileOnchange = "javascript: | ||
| 92 | + var arrPath=this.value.split('/'); | ||
| 93 | + if(arrPath.length == 1){ | ||
| 94 | + var arrPath=this.value.split('\\\'); | ||
| 95 | + } | ||
| 96 | + var name=arrPath[arrPath.length-1]; | ||
| 97 | + var title=name.split('.'); | ||
| 98 | + document.getElementById('document_name').value=title[0];"; | ||
| 99 | + | ||
| 89 | $oForm->setWidgets(array( | 100 | $oForm->setWidgets(array( |
| 90 | array('ktcore.widgets.file',array( | 101 | array('ktcore.widgets.file',array( |
| 91 | 'label' => _kt('File'), | 102 | 'label' => _kt('File'), |
| 92 | 'description' => _kt('The contents of the document to be added to the document management system.'), | 103 | 'description' => _kt('The contents of the document to be added to the document management system.'), |
| 93 | 'name' => 'file', | 104 | 'name' => 'file', |
| 94 | 'required' => true, | 105 | 'required' => true, |
| 106 | + 'onchange' => $sFileOnchange, | ||
| 95 | )), | 107 | )), |
| 96 | array('ktcore.widgets.string',array( | 108 | array('ktcore.widgets.string',array( |
| 97 | 'label' => _kt('Document Title'), | 109 | 'label' => _kt('Document Title'), |
| 98 | 'description' => sprintf(_kt('The document title is used as the main name of a document throughout %s™.'), APP_NAME), | 110 | 'description' => sprintf(_kt('The document title is used as the main name of a document throughout %s™.'), APP_NAME), |
| 99 | 'name' => 'document_name', | 111 | 'name' => 'document_name', |
| 100 | 'required' => true, | 112 | 'required' => true, |
| 113 | + 'id' => 'document_name', | ||
| 101 | )), | 114 | )), |
| 102 | array('ktcore.widgets.entityselection',array( | 115 | array('ktcore.widgets.entityselection',array( |
| 103 | 'label' => _kt('Document Type'), | 116 | 'label' => _kt('Document Type'), |
templates/ktcore/forms/widgets/file.smarty