Skip to content

Commit

Permalink
[TASK] Improve form error, add an in-page link to the corresponding f…
Browse files Browse the repository at this point in the history
…orm control (WIP)

Related: 962
  • Loading branch information
deoostfrees committed Oct 18, 2024
1 parent 6d83921 commit 2bcbc17
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 18 deletions.
6 changes: 6 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@
<trans-unit id="validationerror_upload_error" resname="validationerror_upload_error">
<source>Upload failed, please check permissions on the server!</source>
</trans-unit>
<trans-unit id="validationerror_container_label" resname="validationerror_container_label">
<source>Problematic form fields</source>
</trans-unit>
<trans-unit id="validationerror_title" resname="validationerror_title">
<source>There are errors in this form</source>
</trans-unit>
<trans-unit id="validationerror_spam" resname="validationerror_spam">
<source>Spam recognized:</source>
</trans-unit>
Expand Down
56 changes: 38 additions & 18 deletions Resources/Private/Partials/Misc/FormError.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,45 @@

<f:form.validationResults>
<f:if condition="{validationResults.flattenedErrors}">
<ul class="powermail_message powermail_message_error">
<f:for each="{validationResults.flattenedErrors}" as="errors">
<f:for each="{errors}" as="singleError">
<li>
<f:if condition="{singleError.message} == 'spam_details'">
<f:then>
<f:translate key="validationerror_spam" /> {singleError.arguments.spamfactor}
</f:then>
<f:else>
<f:if condition="{singleError.arguments.marker}">
<vh:getter.getFieldPropertyFromMarkerAndForm marker="{singleError.arguments.marker}" form="{form}" property="title"/>:
</f:if>
</f:else>
</f:if>
<nav class="powermail_message powermail_message_error" aria-label="{f:translate(key: 'validationerror_container_label')}">
<h2><f:translate key="validationerror_title" /></h2>

<f:translate key="validationerror_{singleError.message}">{singleError.message}</f:translate>
</li>
<ol>
<f:for each="{validationResults.flattenedErrors}" as="errors">
<f:for each="{errors}" as="singleError">
<li>
<f:if condition="{singleError.message} == 'spam_details'">
<f:then>
<f:translate key="validationerror_spam" /> {singleError.arguments.spamfactor}

<f:translate key="validationerror_{singleError.message}">{singleError.message}</f:translate>
</f:then>
<f:else>
<f:if condition="{singleError.arguments.marker}">
<f:if condition="{vh:getter.getFieldPropertyFromMarkerAndForm(marker: singleError.arguments.marker, form: form, property: 'type')} == 'check'
|| {vh:getter.getFieldPropertyFromMarkerAndForm(marker: singleError.arguments.marker, form: form, property: 'type')} == 'radio'">
<f:then>
<a href="#powermail_field_{singleError.arguments.marker}_1">
<vh:getter.getFieldPropertyFromMarkerAndForm marker="{singleError.arguments.marker}" form="{form}" property="title"/>:

<f:translate key="validationerror_{singleError.message}">{singleError.message}</f:translate>
</a>
</f:then>
<f:else>
<a href="#powermail_field_{singleError.arguments.marker}">
<vh:getter.getFieldPropertyFromMarkerAndForm marker="{singleError.arguments.marker}" form="{form}" property="title"/>:

<f:translate key="validationerror_{singleError.message}">{singleError.message}</f:translate>
</a>
</f:else>
</f:if>
</f:if>
</f:else>
</f:if>
</li>
</f:for>
</f:for>
</f:for>
</ul>
</ol>
</nav>
</f:if>
</f:form.validationResults>

0 comments on commit 2bcbc17

Please sign in to comment.