Bug #17621
closedInsertion of more than one items by the Element Browser is allowed when it shouldn't
0%
Description
The backend interface allows to select more than one items by the Element Browser for fields that take references to pages or files and should allow only one item to be inserted.
See proposed solution bellow:
Replace the generated Javascript function: setFormValueOpenBrowser
within the function: dbFileCon
in the file: t3lib/class.t3lib_tceforms.php (line:4761)
with this:
function setFormValueOpenBrowser(mode,params) { //
var cmltemp = new Array();
cmltemp = params.split(\'|\');
var cmlname = cmltemp0;
cmlObj = '.$formObj.'[cmlname+"_list"];
if(cmlObj){
var len = cmlObj.length;
if(cmlObj.size==1 && len>=1){
alert(\'This field takes only one item. Please remove the existing one before attempting to input another.\');
return false;
}
}
var url = "'.$this->backPath.'browser.php?mode="+mode+"&bparams="+params;
browserWin = window.open(url,"Typo3WinBrowser","height=350,width="+(mode=="db"?650:600)+",status=0,menubar=0,resizable=1,scrollbars=1");
browserWin.focus();
}
(issue imported from #M6372)
Updated by Kostas Petrianakis about 17 years ago
Anyone want to integrate this to the source code??
Updated by Oliver Hader about 17 years ago
I can confirm this issue.
But there are other cases that have to be implemented.
You did a work-around if the size of a selector was set to 1. But it's also possible, that there are 10 items allowed (maxitems=10 in TCA) - thus, the element browser shouldn't be allowed to insert more, if there are already 10 items.
I also might happen, that you have no items yet in your forms field, open the Element Browser and insert and item (without closing the Element Browser), then insert another item which isn't allowed if maxitems=1. Thus, the check against maxitems should furthermore be delegated to the Element Browser.
Updated by Oliver Hader about 17 years ago
If you create further patches, please provide them in a unified format, e.g. under linux type:
#> diff -ru typo3.orig/ typo3.modified/
Updated by Benni Mack over 15 years ago
The problem is now solved for fields with size=1. For selects with a bigger size, there is an option to scroll, position and see multiple items, thus the behaviour is different and good in that way. So we have this now:
- If the size of the select is 1, then there is no sorting option, there is not even a way to see that there are multiple items. Thus, if there is only one item allowed, then there should always be one item in there.
- If the size of the select is more than one, then you can scroll through the items if there are more items than the size of the select. If there is a maxitems restriction, then there will be a exclamation mark item if you have too many items in there. You can scroll through the list and remove the appropriate item.