[TYPO3-extbase] Model seems not to be validated

Marco Behnke marco.behnke at innogames.de
Tue Apr 30 09:26:03 CEST 2013


Hey,

thanks for answering me. I will repost it there.

Am 30.04.2013 09:20, schrieb Marc Bastian Heinrichs:
> 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?
>
> _______________________________________________
> TYPO3-team-extbase mailing list
> TYPO3-team-extbase at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-team-extbase
>


-- 

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-team-extbase mailing list