[TYPO3-mvc] Checkbox Viewhelper / boolean

Lorenz Ulrich lorenz-typo3 at visol.ch
Wed Nov 16 12:56:46 CET 2011


Hi everyone

I have setup an Extbase extension (TYPO3 4.6) with the extension builder 
that contains several boolean checkbox fields. In the database, these 
booleans are stored as 0 or 1.

Using the checkbox view helper, I would like to offer the possibility to 
check/uncheck this fields, the current value should be displayed:

<f:form.checkbox property="showEmail1" value="1" />

Now Fluid is complaining about the value of this property:

"Checkbox viewhelpers can only be bound to properties of type boolean or 
array."

Looking at the ViewHelper, this is clear, since Fluid evaluates the 
value for boolean but in the database I have 0 or 1 as values.

if (is_bool($propertyValue)) {
	$checked = $propertyValue === (boolean)$valueAttribute;
}

How do you handle such problems? The easiest workaround is to typecast 
the propertyValue before doing the is_bool check but I'm sure I'm not 
the only one who had this problem.

Thanks for your advice.

Lorenz


More information about the TYPO3-project-typo3v4mvc mailing list