I want to validate a file input field in TYPO3 but it seems that NotEmpty annonation not work on a property of type filereference:
/**
* image
*
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
* @validate NotEmpty
*/
protected $image;
/**
* Returns the image
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $image
*/
public function getImage() {
return $this->image;
}
/**
* Sets the image
*
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $image
* @return void
*/
public function setImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $image) {
$this->image = $image;
}
and this simple fluid mark-up:
<f:render partial="FormErrors" arguments="{field: 'data.image'}" />
<f:form.upload property="image" />
so if try to submit the empty upload form I get the following error message, because the filereference is still null:
Exception while property mapping at property path "":PHP Catchable Fatal Error: Argument 1 passed to Fox\Example\Domain\Model\Data::setImage() must be an instance of TYPO3\CMS\Extbase\Domain\Model\FileReference, null given...