1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Fixed Multiselect dropdown so that an empty value also gets saved.

This commit is contained in:
Cameron
2019-12-02 14:18:25 -08:00
parent 5cf54d07d2
commit 972fa1a29c
4 changed files with 26 additions and 4 deletions

View File

@@ -63,7 +63,7 @@ function loadJSAddons()
e107::css('core', 'bootstrap-select/bootstrap-select.min.css', 'jquery'); e107::css('core', 'bootstrap-select/bootstrap-select.min.css', 'jquery');
e107::js('footer', '{e_WEB}js/bootstrap-select/bootstrap-select.min.js', 'jquery', 2); e107::js('footer', '{e_WEB}js/bootstrap-select/bootstrap-select.min.js', 'jquery', 2);
// e107::css('core', 'bootstrap-multiselect/css/bootstrap-multiselect.css', 'jquery'); // e107::css('core', 'bootstrap-multiselect/css/bootstrap-multiselect.css', 'jquery');
e107::js('footer', '{e_WEB}js/bootstrap-multiselect/js/bootstrap-multiselect.js', 'jquery', 2); e107::js('footer', '{e_WEB}js/bootstrap-multiselect/js/bootstrap-multiselect.js', 'jquery', 2);
// TODO: remove typeahead. // TODO: remove typeahead.

View File

@@ -930,7 +930,7 @@ class news_admin_ui extends e_admin_ui
$this->fields['news_meta_robots']['writeParms']['optArray'] = e107::getSingleton('eResponse')->getRobotTypes(); $this->fields['news_meta_robots']['writeParms']['optArray'] = e107::getSingleton('eResponse')->getRobotTypes();
$this->fields['news_meta_robots']['writeParms']['title'] = e107::getSingleton('eResponse')->getRobotDescriptions(); $this->fields['news_meta_robots']['writeParms']['title'] = e107::getSingleton('eResponse')->getRobotDescriptions();
$this->fields['news_meta_robots']['writeParms']['multiple'] = 1; $this->fields['news_meta_robots']['writeParms']['multiple'] = 1;
//$this->fields['news_meta_robots']['writeParms']['default'] = 'blank'; // $this->fields['news_meta_robots']['writeParms']['default'] = 'blank';
// $this->newspost = new admin_newspost; // $this->newspost = new admin_newspost;
// $this->newspost->news_renderTypes = $this->news_renderTypes; // $this->newspost->news_renderTypes = $this->news_renderTypes;
// $this->newspost->observer(); // $this->newspost->observer();

View File

@@ -3,6 +3,7 @@
* https://github.com/davidstutz/bootstrap-multiselect * https://github.com/davidstutz/bootstrap-multiselect
* *
* Copyright 2012 David Stutz * Copyright 2012 David Stutz
* Modified Dec 2019 by e107
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -565,7 +565,8 @@ $(document).ready(function()
$("select.tbox").each(function() { $("select.tbox").each(function() {
var multi = $(this).attr('multiple'); var multi = $(this).attr('multiple');
var tagName = $(this).attr('name');
if(multi === undefined) if(multi === undefined)
{ {
// $(this).selectpicker(); // causes HTML5 validation alert to be hidden. // $(this).selectpicker(); // causes HTML5 validation alert to be hidden.
@@ -573,7 +574,27 @@ $(document).ready(function()
} }
else else
{ {
$(this).multiselect({ buttonClass: 'btn btn-default'} ); $(this).multiselect({
buttonClass: 'btn btn-default',
buttonText: function(options) {
if (options.length == 0) {
return '(Optional) <b class="caret"></b><input type="hidden" name="' + tagName + '" value="" />'; // send empty value to server so value is saved.
}
else if (options.length > 5) {
return options.length + ' selected <b class="caret"></b>';
}
else {
var selected = '';
options.each(function() {
selected += $(this).text() + ', ';
});
return selected.substr(0, selected.length -2) + ' <b class="caret"></b>';
}
},
});
} }