Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
services
t3o sites
voting.typo3.org
extensions
election
Commits
46ac9bd2
Commit
46ac9bd2
authored
Mar 19, 2019
by
Stefan Busemann
Browse files
[FEATURE] Add custom controller error message
parent
d74ea547
Changes
3
Hide whitespace changes
Inline
Side-by-side
Classes/Controller/FeElectionController.php
View file @
46ac9bd2
<?php
namespace
TYPO3\Election\Controller
;
/*
...
...
@@ -167,7 +168,7 @@ class FeElectionController extends ActionController
public
function
showAction
(
Election
$election
)
{
$this
->
view
->
assign
(
'election'
,
$election
);
$this
->
view
->
assign
(
'results'
,
$election
->
getElectedNomineesAndVotes
());
$this
->
view
->
assign
(
'results'
,
$election
->
getElectedNomineesAndVotes
());
}
...
...
@@ -187,4 +188,18 @@ class FeElectionController extends ActionController
{
return
''
;
}
/**
* A template method for displaying custom error flash messages, or to
* display no flash message at all on errors. Override this to customize
* the flash message in your action controller.
*
* @return string|boolean The flash message or FALSE if no flash message should be set
* @api
*/
protected
function
getErrorFlashMessage
()
{
return
LocalizationUtility
::
translate
(
get_class
(
$this
)
.
'->'
.
$this
->
actionMethodName
.
'()'
,
'election'
);
}
}
Resources/Private/Language/locallang.xlf
View file @
46ac9bd2
...
...
@@ -497,12 +497,17 @@
<!-- FE ELECTION VOTING VALIDATION-->
<trans-unit
id=
"validator.fe.election_voting.election_voting_object.to_many_nominees"
>
<source>
To many votes
</source>
<source>
To many votes
. Please choose only the allowed numbers of nominees.
</source>
</trans-unit>
<trans-unit
id=
"validator.fe.election_voting.election_voting_object.not_an_object"
>
<source>
The received votes are not in a valiid format
</source>
</trans-unit>
<!-- FE ELECTION VOTING ACTION ERRORS-->
<trans-unit
id=
"TYPO3\Election\Controller\FeElectionController->submitVoteAction()"
>
<source>
Your voting can not be updated. Please check all messages.
</source>
</trans-unit>
</body>
</file>
</xliff>
Resources/Private/Templates/FeElection/Vote.html
View file @
46ac9bd2
...
...
@@ -14,10 +14,32 @@
{electionInvitation.electionCircular.election.numberOfVotes} nominees
</f:translate>
</p>
<f:form.validationResults>
<f:if
condition=
"{validationResults.flattenedErrors}"
>
<f:for
each=
"{validationResults.flattenedErrors}"
as=
"errors"
key=
"propertyPath"
>
<ul
class=
"typo3-messages"
>
<f:for
each=
"{errors}"
as=
"error"
>
<li
class=
"alert alert-danger"
>
<p
class=
"alert-message"
>
{error}.
<br>
<small>
Code: {error.code}
</small>
</p>
</li>
</f:for>
</ul>
</f:for>
</f:if>
</f:form.validationResults>
<f:form
action=
"submitVote"
object=
"{electionVoting}"
objectName=
"electionVoting"
>
<f:form.hidden
property=
"electionInvitation"
value=
"{electionInvitation}"
/>
<f:render
partial=
"Model/Nominee/VoteList"
arguments=
"{nominees:electionInvitation.electionCircular.election.nominees}"
/>
<f:form.submit
value=
"vote"
/>
<div
class=
"d-flex justify-content-center"
>
<f:form.submit
class=
"btn btn-success float-md"
value=
"vote"
/>
</div>
</f:form>
<hr>
</f:section>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment