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"), getMLText("keywords"),
$this->getKeywordChooserHtml('adddocform') $this->getKeywordChooserHtml('adddocform')
); );
if(!$nodocumentformfields || !in_array('categories', $nodocumentformfields)) {
$options = array();
$categories = $dms->getDocumentCategories(); $categories = $dms->getDocumentCategories();
foreach($categories as $category) { if($categories) {
$options[] = array($category->getID(), $category->getName()); if(!$nodocumentformfields || !in_array('categories', $nodocumentformfields)) {
} $options = array();
$this->formField( foreach($categories as $category) {
getMLText("categories"), $options[] = array($category->getID(), $category->getName());
array( }
'element'=>'select', $this->formField(
'class'=>'chzn-select', getMLText("categories"),
'name'=>'categories[]', array(
'multiple'=>true, 'element'=>'select',
'attributes'=>array(array('data-placeholder', getMLText('select_category'), array('data-no_results_text', getMLText('unknown_document_category')))), 'class'=>'chzn-select',
'options'=>$options '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)) { if(!$nodocumentformfields || !in_array('sequence', $nodocumentformfields)) {
$this->formField(getMLText("sequence"), $this->getSequenceChooser($folder->getDocuments('s')).($orderby != 's' ? "<br />".getMLText('order_by_sequence_off') : '')); $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(); $categories = $dms->getDocumentCategories();
foreach($categories as $category) { if($categories) {
$options[] = array($category->getID(), $category->getName(), in_array($category, $document->getCategories())); if(!$nodocumentformfields || !in_array('categories', $nodocumentformfields)) {
} $options = array();
$this->formField( foreach($categories as $category) {
getMLText("categories"), $options[] = array($category->getID(), $category->getName(), in_array($category, $document->getCategories()));
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) {
$this->formField( $this->formField(
null, getMLText("categories"),
array( array(
'element'=>'input', 'element'=>'select',
'type'=>'hidden', 'class'=>'chzn-select',
'name'=>'categories[]', '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)) { if(!$nodocumentformfields || !in_array('expires', $nodocumentformfields)) {