[TYPO3-mvc] Validate extbase model fails for straneg reasons

Marco Behnke marco.behnke at innogames.de
Tue Apr 30 09:47:39 CEST 2013


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?
-- 

Marco Behnke
Software Developer Grepolis

InnoGames GmbH
Harburger Schloßstraße 28 (Channel 4) - 21079 Hamburg - Germany
Tel +49 40 7889335-0

Managing Directors: Hendrik Klindworth, Eike Klindworth, Michael Zillmer
VAT-ID: DE264068907 Amtsgericht Hamburg, HRB 108973

http://www.innogames.commarco.behnke at innogames.de



More information about the TYPO3-project-typo3v4mvc mailing list