[TYPO3-english] Model seems not to be validated

Dirk Wenzel wenzel at webfox03.de
Sun Mar 24 16:16:28 CET 2013


Hi Marco,
you should post your question on the typo3.dev list

Kind regards
Dirk

Am 20.03.13 08:58, schrieb Marco Behnke:
>
> i,
>
> first of all sorry if this is not the right list, but there is no list
> related to extbase programming (or I did not find it). I tried the
> extbase team, but got no reply.
>
> 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-english mailing list