diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index ac9d3996..4e2c8f90 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -1354,9 +1354,10 @@ abstract class baseModule { * @param array $autoCompleteValues values for auto-completion * @param integer $fieldSize field size * @param array $htmlIDs reference to array where to add the generated HTML IDs of the input fields + * @param string $cssClasses additional CSS classes of input fields */ protected function addMultiValueInputTextField(&$container, $attrName, $label, $required = false, $length = null, $isTextArea = false, - $autoCompleteValues = null, $fieldSize = null, &$htmlIDs = null) { + $autoCompleteValues = null, $fieldSize = null, &$htmlIDs = null, $cssClasses = '') { $values = array(); if (isset($this->attributes[$attrName][0])) { $values = $this->attributes[$attrName]; @@ -1376,6 +1377,9 @@ abstract class baseModule { for ($i = 0; $i < sizeof($values); $i++) { if (!$isTextArea) { $input = new htmlInputField($attrName . '_' . $i, $values[$i]); + if (!empty($cssClasses)) { + $input->setCSSClasses(array($cssClasses)); + } if (!empty($length)) { $input->setFieldMaxLength($length); } @@ -1392,7 +1396,11 @@ abstract class baseModule { if ($length != null) { $cols = $length; } - $subContainer->addElement(new htmlInputTextarea($attrName . '_' . $i, $values[$i], $cols, 3)); + $textArea = new htmlInputTextarea($attrName . '_' . $i, $values[$i], $cols, 3); + if (!empty($cssClasses)) { + $textArea->setCSSClasses(array($cssClasses)); + } + $subContainer->addElement($textArea); } if (!empty($htmlIDs)) { $htmlIDs[] = $attrName . '_' . $i; diff --git a/lam/lib/modules/yubiKeyUser.inc b/lam/lib/modules/yubiKeyUser.inc index a307c2ff..e4481f62 100644 --- a/lam/lib/modules/yubiKeyUser.inc +++ b/lam/lib/modules/yubiKeyUser.inc @@ -145,7 +145,8 @@ class yubiKeyUser extends baseModule { return $return; } if (empty($objectClass) || in_array($objectClass, $this->attributes['objectClass'])) { - $this->addMultiValueInputTextField($return, $attributeName, _('YubiKey ids'), false, '256', false, null, '50'); + $htmlIds = array(); + $this->addMultiValueInputTextField($return, $attributeName, _('YubiKey ids'), false, '12', false, null, null, $htmlIds, 'lam-prevent-enter'); if (!empty($objectClass)) { $return->addElement(new htmlSpacer(null, '30px'), true); diff --git a/lam/templates/lib/500_lam.js b/lam/templates/lib/500_lam.js index 4e9c5e18..30d0c514 100644 --- a/lam/templates/lib/500_lam.js +++ b/lam/templates/lib/500_lam.js @@ -1100,6 +1100,17 @@ window.lam.html.activateLightboxes = function() { }); }; +/** + * Prevents enter key on input fields with class "lam-prevent-enter". + */ +window.lam.html.preventEnter = function() { + jQuery('.lam-prevent-enter').keypress(function (event) { + if (event.keyCode === 10 || event.keyCode === 13) { + event.preventDefault(); + } + }); +} + window.lam.selfservice = window.lam.selfservice || {}; /** @@ -1161,4 +1172,5 @@ jQuery(document).ready(function() { window.lam.tools.setInitialFocus(); window.lam.tools.schema.select(); window.lam.html.activateLightboxes(); + window.lam.html.preventEnter(); });