Пример #1
0
 /**
  * Validates the entered data for a target group.
  *
  * @param tx_ameosformidable $formidable
  *        the FORMidable object for the AJAX call
  * @param array[] $formData
  *        the entered form data, the key must be stripped of the
  *        "newTargetGroup_"/"editTargetGroup_" prefix
  *
  * @return string[] the error messages, will be empty if there are no validation errors
  */
 private static function validateTargetGroup(tx_ameosformidable $formidable, array $formData)
 {
     $validationErrors = array();
     if (trim($formData['title']) == '') {
         $validationErrors[] = $formidable->getLLLabel('LLL:EXT:seminars/Resources/Private/Language/FrontEnd/locallang.xml:message_emptyTitle');
     }
     if (preg_match('/^(\\d*)$/', trim($formData['minimum_age'])) && preg_match('/^(\\d*)$/', trim($formData['maximum_age']))) {
         $minimumAge = $formData['minimum_age'];
         $maximumAge = $formData['maximum_age'];
         if ($minimumAge > 0 && $maximumAge > 0) {
             if ($minimumAge > $maximumAge) {
                 $validationErrors[] = $formidable->getLLLabel('LLL:EXT:seminars/Resources/Private/Language/FrontEnd/locallang.xml:' . 'message_targetGroupMaximumAgeSmallerThanMinimumAge');
             }
         }
     } else {
         $validationErrors[] = $formidable->getLLLabel('LLL:EXT:seminars/Resources/Private/Language/FrontEnd/locallang.xml:message_noTargetGroupAgeNumber');
     }
     return $validationErrors;
 }