[TYPO3-extbase] Model seems not to be validated

Marc Bastian Heinrichs typo3 at mbh-web.de
Tue Apr 30 09:20:39 CEST 2013


Hej,

sorry, this is the extbase team list and not a support list.
For support questions etc. please use typo3.projects.typo3v4mvc
Thanks

cheers
Maba

Am 11.03.2013 10:21, schrieb Marco Behnke:
> Hi,
> 
> first of all sorry if this is not the right list, but there is no other
> list related to extbase (or I did not find it).
> 
> Yesterday I struggled a lot with creating an extbase extension. Checkbox
> elements claim that they want booleans and not strings and so on.
> 
> But my main problem is, that the model does not get validated but
> insreted into the database which results in query errors because the
> content is invalid.
> 
> This is my controller action:
> 
> /**
>  * action new
>  *
>  * @param Tx_ArArbeitnehmer_Domain_Model_Employee $newEmployee
>  * @dontvalidate
>  * @return void
>  */
> public function newAction(Tx_ArArbeitnehmer_Domain_Model_Employee
> $newEmployee = NULL) {
>     if (empty($newEmployee)) {
>         $newEmployee = $this->createEmptyObject();
>     }
>     $this->view->assign('newEmployee', $newEmployee);
> }
> 
> /**
>  * action create
>  *
>  * @param Tx_ArArbeitnehmer_Domain_Model_Employee $newEmployee
>  * @return void
>  */
> public function createAction(Tx_ArArbeitnehmer_Domain_Model_Employee
> $newEmployee) {
>     $this->employeeRepository->add($newEmployee);
>     $this->flashMessageContainer->add('Your new Employee was created.');
> 
>     $this->redirectToUri('/suche/fuer-arbeitnehmer/ihr-eintrag-vielen-dank.html');
> 
> }
> 
> I tried removing the dontvalidate on the newAction but that results in:
> 
> Could not ultimately dispatch the request after 101 iterations. Most
> probably, a @dontvalidate annotation is missing on re-displaying a form
> with validation errors.
> 
> 
> This is my model:
> 
> class Tx_ArArbeitnehmer_Domain_Model_Employee extends
> Tx_Extbase_DomainObject_AbstractEntity {
> 
>     /**
>      * Vorname
>      *
>      * @var string
>      * @validate NotEmpty
>      * @validate StringLength(minimum=1)
>      */
>     protected $firstname = '';
> 
>     /**
>      * Nachname
>      *
>      * @var string
>      * @validate NotEmpty
>      * @validate StringLength(minimum=1)
>      */
>     protected $lastname = '';
> 
> ...
> }
> 
> 
> I tried it with only NotEmpty and with the StringLength but whatever is
> entered in there, the model is saved (or at least tried). I would
> expecte the controller to return with validation errors.
> 
> 
> What am I doing wrong?



More information about the TYPO3-team-extbase mailing list