Check if the form has been sent

@return bool true if the form has been found
168142
private function fetchForm() : bool
    {
        // Get the field keys
        $form_key = preg_grep('/^form_' . preg_quote($this->name, '/') . '_[a-f0-9]+$/', array_keys($_SESSION));
        if (empty($form_key)) {
            return false;
        }
        $this->key = array_values($form_key)[0];

        // Save properties
        foreach ($_SESSION[$this->key] as $key => $value) {
            if (substr($key, -2) === '[]') {
                $this->keys[substr($key, 0, -2)] = $value;
            } else {
                $this->keys[$key] = $value;
            }
        }
        return true;
    }
872966
public function checkIfReady()
    {
        if (!$this->attrs->paramsDone || !$this->attrs->inputDone) {
            return false;
        }
        if (isset($this->appInstance->passphrase)) {
            if (!isset($this->attrs->server['PASSPHRASE'])
                || ($this->appInstance->passphrase !== $this->attrs->server['PASSPHRASE'])
            ) {
                $this->finish();
            }

            return false;
        }

        if ($this->attrs->input->isFrozen()) {
            return false;
        }

        if ($this->sleepTime === 0) {
            $this->wakeup();
        }

        return true;
    }
5262
public function isCsrfValid()
    {
        // csrf protection is disabled.
        if (!$this->isCsrfProtectionEnabled()) {
            return true;
        }

        // the form is not submitted
        if (!$this->isSubmitted()) {
            return true;
        }

        // the form is valid, so the csrf is also valid.
        if ($this->isValid()) {
            return true;
        }

        // the form is invalid. Let's check if the CSRF value is the problem.
        foreach ($this->fields as $field) {
            if ($field instanceof AbstractFormField && $field->getName() == 'csrftoken' && !$field->isValid()) {
                return false;
            }
        }

        // the field is not the problem...
        return true;
    }
440268
private function _hasRecaptcha()
    {
        $action = AnRequest::get('post.action', 'cmd', 'add');

        if ($action == 'add' && $this->_id === 0) {
            if ($this->_option === 'com_people' && $this->_viewer->guest()) {
                if ($this->_view === 'session') {
                    return true;
                }
                if ($this->_view === 'person') {
                    return true;
                }
            }

            if ($this->_option === 'com_groups' && $this->_view === 'group') {
                return true;
            }
        }

        return false;
    }
1116090
public function hasMessage()
    {
        $has_message = false;

        foreach ($this->replicators as $replicator_id) {
            foreach ($this->input_cells as $cell) {
                if ($cell->getWidget($replicator_id)->hasMessage()) {
                    $has_message = true;
                    break 2;
                }
            }
        }

        return $has_message;
    }
32692
public function isSupported()
    {
        $mixer   = $this->getMixer();
        $request = $mixer->getRequest();

        // Support HTML GET requests and also form submits (so we can render errors on POST)
        if(($request->isFormSubmit() || $request->isGet()) && $request->getFormat() == 'html' && !$request->isAjax()) {
            return parent::isSupported();
        }

        return false;
    }
542587
public function has_submissions_or_grades() {
        $allgrades = $this->count_grades();
        $allsubmissions = $this->count_submissions();
        if (($allgrades == 0) && ($allsubmissions == 0)) {
            return false;
        }
        return true;
    }
456646
public function isSuccess()
    {
        $summary = $this->getMessageSummary();

        foreach ($summary as $code => $message) {
            if ("9" == substr($code, 0, 1)) {
                return false;
            }
        }

        return true;
    }
829345
public function hasNextPost()
    {
        return ($this->nextPost && $this->nextPost->ID !== $this->get('ID')) ? true : false;
    }
216456
public function isDiscarded()
    {
        $deleteAfter = strtotime(self::config()->get('delete_after'), strtotime($this->Created));
        return ($this->Status === 'CART') && (time() > $deleteAfter);
    }
907493
public function IsMyPostBack() {
      switch (strtolower($this->Method)) {
         case 'get':
            return count($_GET) > 0 || (is_array($this->FormValues()) && count($this->FormValues()) > 0) ? TRUE : FALSE;
         default:
            return Gdn::Request()->IsPostBack();
      }
   }
412222
public static function isComplete(Form $form)
    {
        //Set the return value to true by default
        $ret = true;

        //Foreach child of the form
        foreach($form->all() as $child) {
            //If the child is required, check that its set
            if ($child->isRequired()) {
                if ($child->isEmpty()) {
                    $ret = false;
                    break;
                }
            }
        }

        //Return
        return $ret;
    }
206118
public function hasPrevPost()
    {
        return ($this->prevPost && $this->prevPost->ID !== $this->get('ID')) ? true : false;
    }
161406
public function callbackSubmit()
    {
        // Get values from the submitted form
        $name       = $this->form->value("name");
        $email       = $this->form->value("email");
        $password      = $this->form->value("password");
        $passwordAgain = $this->form->value("password-again");

        // Check password matches
        if ($password !== $passwordAgain) {
            $this->form->rememberValues();
            $this->form->addOutput("Password did not match.");
            return false;
        }

        if (strpos($name, '%') !== false) {
            $this->form->addOutput("% is not allowed");
            return false;
        }

         $user = new User();
         $user->setDb($this->di->get("db"));

        if ($user->userExists($name)) {
             $this->form->addOutput("User already exists");
             return false;
        }

          $user->name = $name;
          $user->email = $email;
          $user->authority = $this->form->value("select");
          $user->setPassword($password);
          $user->save();

          $this->form->addOutput("You added the user");
          return true;
    }
1208040
protected function saveData()
    {
        // If form is valid, but contains messages, do show them. Most likely these are the not enforced password rules
        if ($this->_form->getMessages()) {
            $this->addMessage($this->_form->getMessages());
        }
        $this->addMessage($this->_('New password is active.'));

        // If the password is valid (for the form) then it is saved by the form itself.
        return 1;
    }
1051191
public function isValid()
    {
        // get the submitted value
        $value = $this->field->getForm()->getFieldValue($this->field->getName());

        // required but not given
        if ($this->required && $value == null) {
            return false;
        } // if the field is not required and the value is empty, then it's also valid
        elseif (!$this->required && $value == "") {
            return true;
        }

        // check if multiple values are returned and if this is allowed.
        if (is_array($value) && !$this->field->isMultiple()) {
            return false;
        }

        // check if the submitted value(s) are in the options value's
        $options = $this->field->getOptions();

        if (!is_array($value)) {
            $value = (array)$value;
        }

        // check if the selected options exist
        if (!$this->checkIfOptionsExists($value, $options)) {
            return false;
        }

        return true;
    }
835032
protected function verifyRequest() : bool
    {
        if (!$this->request->has('g-recaptcha-response')) {
            $this->redirectMessage = 'Recaptcha was not completed';

            return false;
        }

        $data = $this->getRecaptchaResult();

        $success = isset($data->success) ? (bool) $data->success : false;

        if ($success) {
            return true;
        }

        $this->redirectMessage = 'Recaptcha was invalid';

        return false;
    }