Commit 46ac9bd2 authored by Stefan Busemann's avatar Stefan Busemann
Browse files

[FEATURE] Add custom controller error message

parent d74ea547
<?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');
}
}
......@@ -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>
......@@ -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>
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