Answers an array of the validator attributes for the given form.

@param Form $form

@return array
491358
public function getAttributesForForm(Form $form)
    {
        // Obtain Attributes (from parent):
        
        $attributes = parent::getAttributesForForm($form);
        
        // Define Group Class:
        
        $attributes['data-group-class'] = $this->config()->group_class;
        
        // Define Error Wrapper Class:
        
        $attributes['data-error-wrapper-class'] = $this->config()->error_wrapper_class;
        
        // Define Error Classes:
        
        $attributes['data-group-error-class']   = $this->config()->group_error_class;
        $attributes['data-field-error-class']   = $this->config()->field_error_class;
        
        // Define Success Classes:
        
        $attributes['data-group-success-class'] = $this->config()->group_success_class;
        $attributes['data-field-success-class'] = $this->config()->field_success_class;
        
        // Define Trigger Events:
        
        $attributes['data-parsley-trigger'] = $this->getTriggerOn();
        
        // Answer Attributes:
        
        return $this->flatten($attributes);
    }
66821
public function getJsValidator($form = null, $onLoad = true, $wrapped = true)
    {
        if ($form instanceof FormView) {
            $form = $form->vars['name'];
        }
        $jsModels = $this->getFactory()->getJsValidatorString($form, $onLoad);
        if ($wrapped) {
            $jsModels = '<script type="text/javascript">' . $jsModels . '</script>';
        }

        return $jsModels;
    }
467969
public function getFormId(FormInterface $form)
    {
        if (is_object($form->getData())) {
            $ret = preg_replace('/\W/', '_', get_class($form->getData()));
        } else {
            if ($form->getName()) {
                return (string)$form->getName();
            } else {
                return preg_replace('/\W/', '_', get_class($form));
            }
        }
        return $ret;
    }
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;
    }
592981
public function getFieldsValidDataAttributes()
    {
        $result = [];
        $formConfiguration = $this->getFormObject()->getConfiguration();
        $formResult = $this->getFormObject()->getFormResult();

        foreach ($formConfiguration->getFields() as $field) {
            $fieldName = $field->getName();

            if (false === $formResult->fieldIsDeactivated($field)
                && false === $formResult->forProperty($fieldName)->hasErrors()
            ) {
                $result[self::getFieldDataValidKey($fieldName)] = '1';
            }
        }

        return $result;
    }
9989
static function getDataValidator($data, $form = null) {
        $v = static::getVendor();
        if ($v) {
            $v .= '::';
        }
        $filters = (array)\Config::get($v . 'models/' . static::getEntity() . '/filters');
        $rules   = (array)\Config::get($v . 'models/' . static::getEntity() . '/rules');
        $rules = Arr::only($rules, array_keys($data));
//        dump($data);
//        dd($rules);





        //        dump($rules);
        //        \Debugbar::addMessage($rules);
        \Debugbar::addMessage($data);
        $labels   = static::getEntityLabels();
        $messages = static::getEntityValidationMessage();
        \Debugbar::addMessage($labels);
        \Debugbar::addMessage($messages);
        foreach ($filters as $field => $field_filters) {
            //            $field_filters = ['trim'] + $field_filters;
            foreach ($field_filters as $field_filter) {
                $elements  = $form ? $form->getElementsByName($field) : [];
                $options   = [];
                $options[] = Arr::get($data, $field);
                if ($field_filter instanceof \Closure) {
                    $options[] = $data;
                    $options[] = $elements;
                }
                if (isset($data[$field])) {
                    $data[$field] = call_user_func_array($field_filter, $options);
                }
            }
        }
        $class     = static::getClassDataValidator();
        $validator = new $class;

        return $validator->setData((array)$data)->setRules((array)$rules)->setLabels((array)$labels)->setMessages((array)$messages);
    }
942139
public function get_dataset_definitions_category($form) {
        global $CFG, $DB;
        $datasetdefs = array();
        $lnamemax = 30;
        if (!empty($form->category)) {
            $sql = "SELECT i.*, d.*
                      FROM {question_datasets} d, {question_dataset_definitions} i
                     WHERE i.id = d.datasetdefinition AND i.category = ?";
            if ($records = $DB->get_records_sql($sql, array($form->category))) {
                foreach ($records as $r) {
                    if (!isset ($datasetdefs["{$r->name}"])) {
                        $datasetdefs["{$r->name}"] = $r->itemcount;
                    }
                }
            }
        }
        return $datasetdefs;
    }
1180211
public function getFormValues()
    {
        $this->verifyLayout();
        
        $values = array();

        foreach ($this->layout->getChildrenByType('\\Zepi\\Web\\UserInterface\\Form\\Form', true) as $form) {
            $values = $this->extractFormValues($form);
        }
        
        return $values;
    }
1043270
protected function resetPasswordFirstStep($form)
    {
        $loginMail = $form->getSubmitValue('form_login');
        $password  = $form->getSubmitValue('form_password');

        try {
            $this->passwordResetter->initiatePasswordResetProcess($loginMail, $password);
        } catch (Exception $ex) {
            Log::debug($ex);

            return array($ex->getMessage());
        }

        return null;
    }
1048407
public function getErrorMessages(FormInterface $form, bool $useLabels = false, array $errors = []):array
    {
        if ($form->count() > 0) {
            foreach ($form->all() as $child) {
                if (!$child->isValid()) {
                    $errors = $this->getErrorMessages($child, $useLabels, $errors);
                }
            }
        }

        foreach ($form->getErrors() as $error) {
            if ($useLabels) {
                $fieldNameData = $this->getErrorFormLabel($form);
            } else {
                $fieldNameData = $this->getErrorFormId($form);
            }

            $fieldName = $fieldNameData;

            if ($useLabels) {
                /**
                 * @ignore
                 */
                $fieldName = $this->translator->trans($fieldNameData['label'], array(), $fieldNameData['domain']);
            }

            $errors[$fieldName] = $error->getMessage();
        }

        return $errors;
    }
1317393
private function getValidatorOptions(Request $request): array
    {
        if (false === $request->attributes->has(Rest\Action::NAME)) {
            return [
                'groups' => [],
                'attribute' => 'violations',
                'throwable' => true,
            ];
        }

        return $request->attributes->get(Rest\Action::NAME)->getValidator();
    }
127468
protected static function extractChoiceLoader($form)
    {
        $form = static::getForm($form);
        $choiceLoader = $form->getAttribute('choice_loader', $form->getOption('choice_loader'));

        return $choiceLoader;
    }
982433
public function getFormErrors(FormInterface $form, $transDomain = 'System'): array
    {
        if (!$form->isSubmitted() || false) return [];

        $messages = $this->getMessageManager();

        $errorList = $this->getParser()->parseErrors($form);
        $errorList = is_array($errorList) ? $errorList: [];

        foreach($errorList as $q=>$w) {
            $errorList[$q]['messages'] = [];
            foreach($w['errors'] as $error) {
                $errorList[$q]['messages'][] = $error->getMessage();
                $messages->addMessage('danger', $error->getMessage(), [], false);
            }
        }
        if (empty($errorList))
            $messages->addMessage('success', 'All details were saved successfully.', [], 'System');

        return $messages->serialiseTranslatedMessages($this->getTranslator());
    }
1273279
protected function addFormElements(\Zend_Form $form)
    {
        $this->saveLabel = $this->_('Save Two Factor Setup');

        $this->authenticator->addSetupFormElements($form, $this->user, $this->formData);

        if ($this->user->canSaveTwoFactorKey()) {
            $options = [
                'label' => $this->_('Enabled'),
                ];

            $keyElement = $form->createElement('Checkbox', 'twoFactorEnabled', $options);
            $form->addElement($keyElement);
        }
    }
16201
public static function get() : array
  {
    return [
      'csrf_token' => CSRF::generate(),
      'errors' => Variable::has('validation.errors') ? Variable::get('validation.errors') : (new ValidatorFactory())->make([], [])->errors(),
      'old' => Variable::has('form.old') ? Variable::get('form.old') : [],
    ];
  }
178480
protected function questionFrom(FormInterface $form)
    {
        $question = $this->translator->trans(FormUtil::label($form), [], $this->translationDomainFrom($form));

        return $this->formattedQuestion($question, $this->defaultValueFrom($form));
    }
1049877
protected function getConditionBuilder(Form $form)
    {
        $builderClosure = $form->getConfig()->getAttribute('filter_condition_builder');

        $builder = new ConditionBuilder();

        if ($builderClosure instanceof \Closure) {
            $builderClosure($builder);
        } else {
            $this->buildDefaultConditionNode($form, $builder->root('AND'));
        }

        return $builder;
    }