[TYPO3-mvc] How to validate checkboxes?
Helmut Hummel
helmut.hummel at typo3.org
Tue Sep 16 10:59:54 CEST 2014
Hi Stefan,
On 16.09.14 08:00, Stefan Kruse wrote:
> could anybody give me a example of how to validate a checkbox? In my model i have the anno @validate NotEmpty.
> But when i submit my form, the checkbox was not validated. I could leave this field empty and the form was submitted.
>
> Maybe some hints?
I also ran into this recently. The "trick" is to add a value to your
checkbox view helper:
<f:form.checkbox property="legalAgreement" value="false"/>
And to annotate the following in your model:
/**
* @var bool
* @validate Boolean(is=true)
*/
protected $legalAgreement;
Kind regards,
Helmut
--
Helmut Hummel
Release Manager TYPO3 6.0
TYPO3 CMS Active Contributor, TYPO3 Security Team Member
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the TYPO3-project-typo3v4mvc
mailing list