Commit 18102958633a606b3e9dfc065bd55eab9437b67d

Authored by Jonathan Byrne
1 parent 623d4f57

KTS-2865

"Conditional metadata fieldsets failing validation"

Fixed. Added a proper required field check so non-required unset condiional fields pass the validation.

Committed By: Jonathan Byrne
Reviewed By: Jalaloedien Abrahams

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@8020 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktcore/KTValidators.php
... ... @@ -381,7 +381,17 @@ class KTMembershipValidator extends KTValidator {
381 381 implode(', ', $failed)));
382 382 }
383 383 } else {
384   - if (!$this->aVocab[$val]) {
  384 +
  385 + $mandatory=true;
  386 +
  387 + if (substr($this->sInputVariable, 0, 9) == 'metadata_')
  388 + {
  389 + $fieldid = substr($this->sInputVariable, 9);
  390 + $field = DocumentField::get($fieldid);
  391 + $mandatory = $field->getIsMandatory();
  392 + }
  393 +
  394 + if (!array_key_exists($val, $this->aVocab) && $mandatory) {
385 395 $errors[$this->sBasename] = KTUtil::arrayGet($this->aOptions,
386 396 'error_message', sprintf(_kt('"%s"is not a valid selection.'), $val));
387 397 }
... ...
plugins/ktcore/folder/addDocument.php
... ... @@ -285,6 +285,13 @@ class KTFolderAddDocumentAction extends KTFolderAction {
285 285  
286 286 foreach ($fields as $oField) {
287 287 $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId());
  288 + if ($oFieldset->getIsConditional())
  289 + {
  290 + if ($val == _kt('No selection.'))
  291 + {
  292 + $val = null;
  293 + }
  294 + }
288 295 // ALT.METADATA.LAYER.DIE.DIE.DIE
289 296 if (!is_null($val)) {
290 297 $MDPack[] = array(
... ...