CoreCommunity ExtensionsIncubatorDistributionsTYPO3 4.5 ProjectsTYPO3 4.6 ProjectsTYPO3 4.7 ProjectsTYPO3 6.0 ProjectsTYPO3 6.1 ProjectsTYPO3 6.2 Projects (+)

Support #30402

Error labels

Added by Rainer Becker over 1 year ago. Updated over 1 year ago.

Status:Resolved Start date:2011-09-28
Priority:Should have Due date:
Assignee:Reinhard Führicht % Done:

100%

Category:-
Target version:Stable v1.0
Votes: 1 (View)

Description

Right now I have a label for every single error message:

<label index="error_firstname_required">Vorname ist nicht ausgefüllt!</label>
<label index="error_street_required">Straße ist nicht ausgefüllt!</label>
<label index="error_town_required">Ort ist nicht ausgefüllt!</label>
<label index="error_lastname_required">Nachname ist nicht ausgefüllt!</label>

Is there a way to shorten this with a kind of error master template? Like:

<label index="error_default_required">###fieldname### ist nicht ausgefüllt!</label>

Advantages:
  • Less work ;-)
  • Less clutter in lang file
  • No risk of forgetting to add an error label
  • No more redundancies of field names in lang file

30402.patch (1.7 kB) Reinhard Führicht, 2011-09-28 19:32

Associated revisions

Revision 52581
Added by Reinhard Führicht over 1 year ago

Add possibility to define generic error messages for a specific error check (resolves #30402)

Revision 52581
Added by Reinhard Führicht over 1 year ago

Add possibility to define generic error messages for a specific error check (resolves #30402)

History

Updated by Reinhard Führicht over 1 year ago

  • File 30402.patch added
  • Status changed from New to Accepted
  • Assignee set to Reinhard Führicht
  • Target version set to Stable v1.0

Attached patch tries to make this possible.

  • You can define error messages per error check (index="error_[check]")
  • You can use ###fieldname### in your error messages
  • I switched the call order of the marker replacement so that error markers get replaced before the lang markers. This way you can do stuff like this:
<label index="error_required">Please enter your ###LLL:###fieldname######!</label>

Please let me know, if this is what you expected.

Updated by Rainer Becker over 1 year ago

Now I can use

<label index="error_required">Please enter your ###fieldname###!</label>

(without LLL:) to show the not so nice fieldname, but much better now I can use:
<label index="error_required">Please enter your ###LLL:label_###fieldname######!</label>

for the nicer field label – this is pretty cool!

If this should be added to the trunk and documented it should be pointed out that a generic error message (like error_required) is only shown if the more special one (error_email_required) is not available in the current and the default language - or the error message lookup order has to be changed:
1. specific errormessage current language
2. generic errormessage current language
3. specific errormessage default language
4. generic errormessage default language

Updated by Rainer Becker over 1 year ago

I found one limitation: Using a generic E-Mail-Errormessage:

<label index="error_email">###LLL:label_###fieldname###### ist keine gültige E-Mail-Adresse!</label>

will break if a field named "email" exists with a specific error message.
Should the error check "email" be renamed to "validemail"?

Updated by Reinhard Führicht over 1 year ago

I think it would be best to rename the key to something like error_default_[check] as you suggested. No one should use "default" as a field name anyway. :-)
I will change this and add some documentation.

Updated by Reinhard Führicht over 1 year ago

  • Status changed from Accepted to Resolved
  • % Done changed from 0 to 100

Applied in changeset r52581.

Also available in: Atom PDF