Skip to content

Commit

Permalink
pkp#3157 fix required tagit metadata fields validation
Browse files Browse the repository at this point in the history
  • Loading branch information
bozana authored and NateWr committed Jan 8, 2018
1 parent 10211fa commit 1e164b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions classes/submission/PKPSubmissionMetadataFormImplementation.inc.php
Expand Up @@ -66,6 +66,10 @@ function() use ($submission) {
if ($context->getSetting($key . 'Required')) switch(1) {
case in_array($key, $this->getLocaleFieldNames()):
$this->_parentForm->addCheck(new FormValidatorLocale($this->_parentForm, $key, 'required', 'common.required', $submission->getLocale()));
break;
case in_array($key, $this->getTagitFieldNames()):
$this->_parentForm->addCheck(new FormValidatorCustom($this->_parentForm, $key, 'required', 'common.required', create_function('$key,$form,$name', '$data = $form->getData(\'keywords\'); return array_key_exists($name, $data);'), array($this->_parentForm, $submission->getLocale().'-'.$key)));
break;
case $key == 'citations':
$request = Application::getRequest();
$user = $request->getUser();
Expand Down Expand Up @@ -138,6 +142,14 @@ function getLocaleFieldNames() {
return array('title', 'prefix', 'subtitle', 'abstract', 'coverage', 'type', 'source', 'rights');
}

/**
* Get the names of fields for which tagit is used
* @return array
*/
function getTagitFieldNames() {
return array('subjects', 'keywords', 'disciplines', 'agencies', 'languages');
}

/**
* Save changes to submission.
* @param $submission Submission
Expand Down
2 changes: 1 addition & 1 deletion templates/submission/submissionMetadataFormFields.tpl
Expand Up @@ -15,7 +15,7 @@
{assign var=citationsEnabled value=false}
{/if}
{if $coverageEnabled || $typeEnabled || $sourceEnabled || $rightsEnabled ||
$languagesEnabled || $subjectEnabled || $keywordsEnabled || $agenciesEnabled || $citationsEnabled}
$languagesEnabled || $subjectEnabled || $keywordsEnabled || $agenciesEnabled || $citationsEnabled || $disciplinesEnabled}
{fbvFormSection title="submission.metadata"}
<p class="description">{translate key="submission.metadataDescription"}</p>
{/fbvFormSection}
Expand Down

0 comments on commit 1e164b5

Please sign in to comment.