Commit 967aba1f authored by Carsten  Rose's avatar Carsten Rose
Browse files

F6178 / Input Step: min/max adjusted to be a multiple of 'step'.

parent 3b0f03ed
......@@ -1189,6 +1189,7 @@ abstract class AbstractBuildForm {
}
$formElement = HelperFormElement::prepareExtraButton($formElement, !$flagTextarea);
if ($flagTextarea) {
$htmlTag = '<textarea';
......
......@@ -27,8 +27,6 @@ class Support {
* @throws UserFormException
*/
public static function appendTypo3ParameterToArray(array &$queryArray, $mode = PARAM_T3_ALL) {
// if (isset($_GET['id']))
// $queryArray['id'] = self::getCurrentPage();
$store = Store::getInstance();
......@@ -612,8 +610,7 @@ class Support {
*
* @return mixed
*/
public
static function encryptDoubleCurlyBraces($text) {
public static function encryptDoubleCurlyBraces($text) {
$text = str_replace('{{', LONG_CURLY_OPEN, $text);
$text = str_replace('}}', LONG_CURLY_CLOSE, $text);
......@@ -764,7 +761,7 @@ class Support {
}
// set typeAheadPedantic
if (isset($formElement[FE_TYPEAHEAD_PEDANTIC]) && $formElement[FE_TYPEAHEAD_PEDANTIC] === '') {
if (isset($formElement[FE_TYPEAHEAD_PEDANTIC]) && $formElement[FE_TYPEAHEAD_PEDANTIC] === '') {
$formElement[FE_TYPEAHEAD_PEDANTIC] = '1'; // support legacy option of 'typeAheadPedantic' without a value
}
if (isset($formElement[FE_TYPEAHEAD_LDAP]) || isset($formElement[FE_TYPEAHEAD_SQL])) {
......@@ -897,8 +894,9 @@ class Support {
}
// Numbers don't need a maxLength because they are being handled by min/max and/or decimalFormat
if ($isANumber)
if ($isANumber) {
$formElement[FE_MAX_LENGTH] = '';
}
if (!empty($formElement[FE_TYPEAHEAD_SQL]) || !empty($formElement[FE_TYPEAHEAD_LDAP])) {
$inputType = '';
......@@ -910,9 +908,20 @@ class Support {
if ($formElement[FE_CHECK_TYPE] === SANITIZE_ALLOW_AUTO) {
$formElement[FE_CHECK_TYPE] = $checkType;
}
if (empty($formElement[FE_MIN])) $formElement[FE_MIN] = $min;
if (empty($formElement[FE_MAX])) $formElement[FE_MAX] = $max;
if (empty($formElement[FE_INPUT_TYPE])) $formElement[FE_INPUT_TYPE] = $inputType;
// If a $formElement[FE_STEP] is given, the optional boundaries (FE_MIN / FE_MAX) have to be aligned to a multiple of $formElement[FE_STEP].
if (!empty($formElement[FE_STEP])) {
if (!empty($formElement[FE_MIN])) {
$formElement[FE_MIN] = ceil($formElement[FE_MIN] / $formElement[FE_STEP]) * $formElement[FE_STEP];
}
if (!empty($formElement[FE_MAX])) {
$formElement[FE_MAX] = floor($formElement[FE_MAX] / $formElement[FE_STEP]) * $formElement[FE_STEP];
}
}
}
/**
......@@ -923,7 +932,7 @@ class Support {
* @param $typeSpec
* @throws UserFormException
*/
private function adjustDecimalFormat(array &$formElement, $typeSpec) {
private static function adjustDecimalFormat(array &$formElement, $typeSpec) {
if (isset($formElement[FE_DECIMAL_FORMAT])) {
if ($formElement[FE_DECIMAL_FORMAT] === '') {
// Get decimal format from column definition
......@@ -954,7 +963,7 @@ class Support {
* @param array $formElement
* @param $typeSpec
*/
private function adjustMaxLength(array &$formElement, $typeSpec) {
private static function adjustMaxLength(array &$formElement, $typeSpec) {
// MIN( $formElement['maxLength'], table definition)
$maxLength = self::getColumnSize($typeSpec);
......@@ -1001,7 +1010,7 @@ class Support {
* @return bool|int a) 'false' if there is no length definition, b) length definition, c)
* date|time|datetime|timestamp use hardcoded length
*/
private function getColumnSize($typeSpec) {
private static function getColumnSize($typeSpec) {
$matches = array();
......@@ -1036,7 +1045,7 @@ class Support {
*
* @return int
*/
private function maxLengthSetEnum($typeSpec) {
private static function maxLengthSetEnum($typeSpec) {
$startPos = (substr($typeSpec, 0, 4) === 'set(') ? 4 : 5;
$max = 0;
......@@ -1065,7 +1074,7 @@ class Support {
* @return array|string
* @throws CodeException
*/
private function applyFormModeToFormElement($feMode, $formMode) {
private static function applyFormModeToFormElement($feMode, $formMode) {
if ($formMode == '') {
return $feMode; //no change
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment