Backend\Modules\Profiles\Actions\AddProfileGroup::validateForm PHP Метод

validateForm() приватный Метод

Validate the form.
private validateForm ( )
    private function validateForm()
    {
        // is the form submitted?
        if ($this->frm->isSubmitted()) {
            // cleanup the submitted fields, ignore fields that were added by hackers
            $this->frm->cleanupFields();
            // get fields
            $ddmGroup = $this->frm->getField('group');
            $txtExpirationDate = $this->frm->getField('expiration_date');
            $txtExpirationTime = $this->frm->getField('expiration_time');
            // fields filled?
            $ddmGroup->isFilled(BL::getError('FieldIsRequired'));
            if ($txtExpirationDate->isFilled()) {
                $txtExpirationDate->isValid(BL::getError('DateIsInvalid'));
            }
            if ($txtExpirationTime->isFilled()) {
                $txtExpirationTime->isValid(BL::getError('TimeIsInvalid'));
            }
            // no errors?
            if ($this->frm->isCorrect()) {
                // build item
                $values['profile_id'] = $this->id;
                $values['group_id'] = $ddmGroup->getSelected();
                $values['starts_on'] = BackendModel::getUTCDate();
                // only format date if not empty
                if ($txtExpirationDate->isFilled() && $txtExpirationTime->isFilled()) {
                    // format date
                    $values['expires_on'] = BackendModel::getUTCDate(null, BackendModel::getUTCTimestamp($txtExpirationDate, $txtExpirationTime));
                }
                // insert values
                $id = BackendProfilesModel::insertProfileGroup($values);
                // trigger event
                BackendModel::triggerEvent($this->getModule(), 'after_profile_add_to_group', array('item' => $values));
                // everything is saved, so redirect to the overview
                $this->redirect(BackendModel::createURLForAction('Edit') . '&id=' . $values['profile_id'] . '&report=membership-added&highlight=row-' . $id . '#tabGroups');
            }
        }
    }