do not allow to select category if no categories exists

This commit is contained in:
Uwe Steinmann 2021-12-03 11:31:37 +01:00
parent 14d8a1bd91
commit 004af591a9
2 changed files with 43 additions and 39 deletions

View File

@ -223,23 +223,25 @@ console.log(params);
getMLText("keywords"),
$this->getKeywordChooserHtml('adddocform')
);
if(!$nodocumentformfields || !in_array('categories', $nodocumentformfields)) {
$options = array();
$categories = $dms->getDocumentCategories();
foreach($categories as $category) {
$options[] = array($category->getID(), $category->getName());
}
$this->formField(
getMLText("categories"),
array(
'element'=>'select',
'class'=>'chzn-select',
'name'=>'categories[]',
'multiple'=>true,
'attributes'=>array(array('data-placeholder', getMLText('select_category'), array('data-no_results_text', getMLText('unknown_document_category')))),
'options'=>$options
)
);
if($categories) {
if(!$nodocumentformfields || !in_array('categories', $nodocumentformfields)) {
$options = array();
foreach($categories as $category) {
$options[] = array($category->getID(), $category->getName());
}
$this->formField(
getMLText("categories"),
array(
'element'=>'select',
'class'=>'chzn-select',
'name'=>'categories[]',
'multiple'=>true,
'attributes'=>array(array('data-placeholder', getMLText('select_category'), array('data-no_results_text', getMLText('unknown_document_category')))),
'options'=>$options
)
);
}
}
if(!$nodocumentformfields || !in_array('sequence', $nodocumentformfields)) {
$this->formField(getMLText("sequence"), $this->getSequenceChooser($folder->getDocuments('s')).($orderby != 's' ? "<br />".getMLText('order_by_sequence_off') : ''));

View File

@ -134,35 +134,37 @@ $(document).ready( function() {
)
);
}
if(!$nodocumentformfields || !in_array('categories', $nodocumentformfields)) {
$options = array();
$categories = $dms->getDocumentCategories();
foreach($categories as $category) {
$options[] = array($category->getID(), $category->getName(), in_array($category, $document->getCategories()));
}
$this->formField(
getMLText("categories"),
array(
'element'=>'select',
'class'=>'chzn-select',
'name'=>'categories[]',
'multiple'=>true,
'attributes'=>array(array('data-placeholder', getMLText('select_category'), array('data-no_results_text', getMLText('unknown_document_category')))),
'options'=>$options
)
);
} else {
$categories = $document->getCategories();
foreach($categories as $category) {
if($categories) {
if(!$nodocumentformfields || !in_array('categories', $nodocumentformfields)) {
$options = array();
foreach($categories as $category) {
$options[] = array($category->getID(), $category->getName(), in_array($category, $document->getCategories()));
}
$this->formField(
null,
getMLText("categories"),
array(
'element'=>'input',
'type'=>'hidden',
'element'=>'select',
'class'=>'chzn-select',
'name'=>'categories[]',
'value'=>htmlspecialchars($category->getId()),
'multiple'=>true,
'attributes'=>array(array('data-placeholder', getMLText('select_category'), array('data-no_results_text', getMLText('unknown_document_category')))),
'options'=>$options
)
);
} else {
$categories = $document->getCategories();
foreach($categories as $category) {
$this->formField(
null,
array(
'element'=>'input',
'type'=>'hidden',
'name'=>'categories[]',
'value'=>htmlspecialchars($category->getId()),
)
);
}
}
}
if(!$nodocumentformfields || !in_array('expires', $nodocumentformfields)) {