[+FEATURE] (ViewHelpers): Adjust Fluid to new Property Mapper
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Form / ValidationResultsViewHelper.php
1 <?php
2
3 /* *
4 * This script belongs to the FLOW3 package "Fluid". *
5 * *
6 * It is free software; you can redistribute it and/or modify it under *
7 * the terms of the GNU Lesser General Public License as published by the *
8 * Free Software Foundation, either version 3 of the License, or (at your *
9 * option) any later version. *
10 * *
11 * This script is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
14 * General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with the script. *
18 * If not, see http://www.gnu.org/licenses/lgpl.html *
19 * *
20 * The TYPO3 project - inspiring people to share! *
21 * */
22
23 /**
24 * Error messages view helper
25 *
26 * = Examples =
27 *
28 * <code title="Output error messages as a list">
29 * <ul class="errors">
30 * <f:form.errors>
31 * <li>{error.code}: {error.message}</li>
32 * </f:form.errors>
33 * </ul>
34 * </code>
35 * <output>
36 * <ul>
37 * <li>1234567890: Validation errors for argument "newBlog"</li>
38 * </ul>
39 * </output>
40 *
41 * <code title="Output error messages for a single property">
42 * <f:form.errors for="someProperty">
43 * <div class="error">
44 * <strong>{error.propertyName}</strong>: <f:for each="{error.errors}" as="errorDetail">{errorDetail.message}</f:for>
45 * </div>
46 * </f:form.errors>
47 * </code>
48 * <output>
49 * <div class="error>
50 * <strong>someProperty:</strong> errorMessage1 errorMessage2
51 * </div>
52 * </output>
53 *
54 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
55 * @api
56 * @scope prototype
57 */
58 class Tx_Fluid_ViewHelpers_Form_ValidationResultsViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
59
60 /**
61 * Iterates through selected errors of the request.
62 *
63 * @param string $for The name of the error name (e.g. argument name or property name). This can also be a property path (like blog.title), and will then only display the validation errors of that property.
64 * @param string $as The name of the variable to store the current error
65 * @return string Rendered string
66 * @author Christopher Hlubek <hlubek@networkteam.com>
67 * @author Sebastian Kurf├╝rst <sebastian@typo3.org>
68 * @api
69 */
70 public function render($for = '', $as = 'validationResults') {
71 $validationResults = $this->controllerContext->getRequest()->getOriginalRequestMappingResults();
72
73 if ($for !== '') {
74 $validationResults = $validationResults->forProperty($for);
75 }
76 $this->templateVariableContainer->add($as, $validationResults);
77 $output = $this->renderChildren();
78 $this->templateVariableContainer->remove($as);
79
80 return $output;
81 }
82 }
83
84 ?>