RomanL 8 years ago
parent
commit
0ca39266a6

+ 2 - 2
inc/js/functions.js

@@ -906,7 +906,7 @@ function bx_get_param(s) {
     return aDolOptions[s];
 }
 
-function bx_autocomplete_fields(iId, sUrl, sName, bShowImg, bOnlyOnce, onSelect, iValsCount){
+function bx_autocomplete_fields(iId, sUrl, sName, bShowImg, bOnlyOnce, onSelect){
 	if (!$('#' + iId).hasClass('bx-form-input-autotoken'))
 			$('#' + iId).addClass('bx-form-input-autotoken');
 	
@@ -922,7 +922,7 @@ function bx_autocomplete_fields(iId, sUrl, sName, bShowImg, bOnlyOnce, onSelect,
 			e.preventDefault();			
 		}
 	});
-	if (iValsCount > 0 && bOnlyOnce)
+	if ($('#' + iId + ' .val').length > 0 && bOnlyOnce)
 		$('#' + iId + ' input[type=text]').hide();
 	$('#' + iId + ' input[type=text]').on('superselect', function(e, item) {
 		$(this).hide();

+ 1 - 1
template/form_field_custom_suggestions.html

@@ -4,6 +4,6 @@
 </div>
 <script>
 	$(function(){
-		bx_autocomplete_fields('__id__','__url_get_recipients__','__name__',__b_img__,__only_once__,__on_select__,__vals_count__);
+		bx_autocomplete_fields('__id__','__url_get_recipients__','__name__',__b_img__,__only_once__,__on_select__);
 	});
 </script>

+ 0 - 3
template/scripts/BxBaseFormView.php

@@ -990,13 +990,11 @@ BLAH;
         ));
 
         $sVals = '';
-        $iValsCount = 0;
         if (!empty($aInput['value']) && is_array($aInput['value'])) {
             foreach ($aInput['value'] as $sVal) {
                 if (!$sVal || !($oProfile = BxDolProfile::getInstance($sVal)))
                     continue;
                $sVals .= '<b class="val bx-def-color-bg-hl bx-def-round-corners">' . $oProfile->getUnit(0, array('template' => 'unit_wo_info')) . $oProfile->getDisplayName() . '<input type="hidden" name="' . $aInput['name'] . '[]" value="' . $sVal . '" /></b>';
-               $iValsCount ++;
             }
             $sVals = trim($sVals, ',');
         }
@@ -1010,7 +1008,6 @@ BLAH;
 			'on_select' => isset($aInput['custom']['on_select']) ? $aInput['custom']['on_select']: 'null',
             'placeholder' => bx_html_attribute(isset($aInput['placeholder']) ? $aInput['placeholder'] : _t('_sys_form_paceholder_profiles_suggestions'), BX_ESCAPE_STR_QUOTE),
             'vals' => $sVals,
-            'vals_count' => $iValsCount,
         ));
     }