TYPO3: TCA eval=int akzeptiert keine 0

Klitzekleines Problem, aber manchmal dennoch wichtig.

Bei einer Extension soll in der Feldeingabe alle Nummerischen Werte geprüft werden, also keine Eingabe von Buchstaben ist erlaubt.

Folgende TCA Konfiguration läßt die Eingabe „0“ nicht zu.

*** FALSCH ***
'config' => array(
    'type' => 'input',
    'size' => 30,
    'eval' => 'int,required'
),

Die Eingabe von „0“ kann wie folgt erreicht werden:

*** RICHTIG ***
'config' => array(
    'type' => 'input',
    'size' => 30,
    'eval' => 'num,required'
),

Folgende Konfigurationsparameter sind für „eval“ verfügbar:
Quelle: TYPO3 Core API – $TCA

  1. required : A non-empty value is required in the field (otherwise the form cannot be saved).
  2. trim : The value in the field will have whitespaces around it trimmed away.
  3. date : The field will evaluate the input as a date, automatically converting the input to a UNIX-time in seconds. The display will be like „12-8-2003“ while the database value stored will be „1060639200“.
  4. datetime : The field will evaluate the input as a date with time (detailed to hours and minutes), automatically converting the input to a UNIX-time in seconds. The display will be like „16:32 12-8-2003“ while the database value will be „1060698720“.
  5. time : The field will evaluate the input as a timestamp in seconds for the current day (with a precision of minutes). The display will be like „23:45“ while the database will be „85500“.
  6. timesec : The field will evaluate the input as a timestamp in seconds for the current day (with a precision of seconds). The display will be like „23:45:13“ while the database will be „85513“.
  7. year : Evaluates the input to a year between 1970 and 2038. If you need any year, then use „int“ evaluation instead.
  8. int : Evaluates the input to an integer.
  9. upper : Converts to uppercase (only A-Z plus a selected set of Western European special chars).
  10. lower : Converts the string to lowercase (only A-Z plus a selected set of Western European special chars).
  11. alpha : Allows only a-zA-Z characters.
  12. num : Allows only 0-9 characters in the field.
  13. alphanum : Same as „alpha“ but allows also „0-9“
  14. alphanum_x : Same as „alphanum“ but allows also „_“ and „-“ chars.
  15. nospace : Removes all occurencies of space characters (chr(32))
  16. md5 : Will convert the inputted value to the md5-hash of it (The JavaScript MD5() function is found in typo3/md5.js)
  17. is_in : Will filter out any character in the input string which is not found in the string entered in the key „is_in“ (see below).
  18. password : Will show „*******“ in the field after entering the value and moving to another field. Thus passwords can be protected from display in the field. Notice that the value during entering it is visible!
  19. double2 : Converts the input to a floating point with 2 decimal positions, using the „.“ (period) as the decimal delimited (accepts also „,“ for the same).
  20. unique : Requires the field to be unique for the whole table. (Evaluated on the server only). NOTICE: When selecting on unique-fields, make sure to select using “AND pid>=0” since the field CAN contain duplicate values in other versions of records (always having PID = -1). This also means that if you are using versioning on a table where the unique-feature is used you cannot set the field to be truely unique in the database either!
  21. uniqueInPid : Requires the field to be unique for the current PID (among other records on the same page). (Evaluated on the server only)
  22. tx_* : User defined form evaluations.
Dieser Beitrag wurde unter TYPO3 veröffentlicht. Setze ein Lesezeichen auf den Permalink.