custom fields validator setter

@param String $on
@param String $event
@param array $attributes
@return \Antares\Html\Form\FormBuilder
963765
public function setCustomFieldsValidator($on, $event, array $attributes = array())
    {
        $this->customFieldsValidator[$on] = [$event => $attributes];
        return $this;
    }
1096913
public function createElement(array $attributes)
    {
        $element = $this->ownerDocument->createElement($this->element);

        $name = null;
        foreach ($attributes as $key => $value) {
            $element->setAttribute($key, $value);
        }

        $this[] = $element;

        return $element;
    }
376173
public function buildAttribute(BuildAttributeEvent $event)
    {
        $attribute = $event->getAttribute();
        if (!($attribute instanceof File) || !$attribute->get('file_multiple')) {
            return;
        }

        $container  = $event->getContainer();
        $properties = $container->getPropertiesDefinition();
        $name       = $attribute->getColName();
        $nameSort   = \sprintf('%s__sort', $name);

        if ($properties->hasProperty($nameSort)) {
            $this->addAttributeToDefinition($container, $name);
            $properties->getProperty($name . '__sort')->setWidgetType('fileTreeOrder');

            return;
        }

        $properties->addProperty($property = new DefaultProperty($name . '__sort'));
        $property->setWidgetType('fileTreeOrder');

        $this->addAttributeToDefinition($container, $name);
    }
699792
public static function create(array $attributes, $runValidation = true)
    {
        $model = new static();
        $model->loadDefaultValues();
        $model->load($attributes, '');
        $model->save($runValidation);
        return $model;
    }
1173471
protected function validate(array $attributes, string $name, array $parameters = []): bool
    {
        $callback = $this->callback;

        if (($result = $callback($attributes, $name, $parameters)) === false) {
            $this->addError($name, $parameters, 'verification failed');
        }

        unset($callback);

        return $result;
    }
985055
public function newFromBuilder($attributes = [], $connection = null)
    {
        $attributes = (array) $attributes;

        if (! empty($attributes['type'])
            && isset(static::$models[$attributes['type']])
            && class_exists($class = static::$models[$attributes['type']])
        ) {
            /** @var Post $instance */
            $instance = new $class;
            $instance->exists = true;
            $instance->setRawAttributes($attributes, true);
            $instance->setConnection($connection ?: $this->connection);

            return $instance;
        }

        return parent::newFromBuilder($attributes, $connection);
    }
396353
public function validate($value, $validator, $attributes)
    {
        $validator = $this->getValidator($validator);

        $result = $validator->validate($value, $attributes);

        return $negative ? ! $result : $result;
    }
661649
public function containerAttributes(array $attributes = []): Builder
    {
        foreach ($this->containerAttributes as $name => $value) {
            if (is_null($param = array_get($attributes, $name))) {
                continue;
            }
            array_set($this->containerAttributes, $name, $value . ' ' . $param);
        }
        return $this;
    }
1115808
public function _attrEventBeforeUpdate(&$attributes)
    {
        // Auto updated_by
        if ($this->updatedUserAttribute && !isset($attributes[$this->updatedUserAttribute])) {
            $attributes[$this->updatedUserAttribute] = $this->user->getID();
        }
        return parent::_attrEventBeforeUpdate($attributes);
    }
141032
public function evaluateAttributes($event)
    {
        if (isset($this->attributes[$event->name])) {
            $enumList = $this->attributes[$event->name];
            if ($this->changeOriginal) {
                if ($event->name == ActiveRecord::EVENT_BEFORE_VALIDATE) {
                    foreach ($enumList as $attribute => $values) {
                        $this->enumData[$attribute . 'List'] = $values;
                        $this->enumData[$attribute . 'Name'] = $this->owner->$attribute;
                        $values = array_flip($values);
                        $valueName = isset($values[$this->owner->$attribute]) ? $values[$this->owner->$attribute] : $this->owner->$attribute;
                        $this->enumData[$attribute . 'Value'] = $valueName;
                        $this->owner->$attribute = $valueName;
                    }
                }
                if (in_array($event->name, [ActiveRecord::EVENT_AFTER_FIND, ActiveRecord::EVENT_AFTER_INSERT, ActiveRecord::EVENT_AFTER_UPDATE])) {
                    foreach ($enumList as $attribute => $values) {
                        $this->enumData[$attribute . 'List'] = $values;
                        $this->enumData[$attribute . 'Value'] = $this->owner->$attribute;
                        $valueName = isset($values[$this->owner->$attribute]) ? $values[$this->owner->$attribute] : $this->owner->$attribute;
                        $this->enumData[$attribute . 'Name'] = $valueName;
                        $this->owner->$attribute = $valueName;
                    }
                }
            } else {
                if ($event->name == ActiveRecord::EVENT_AFTER_FIND) {
                    foreach ($enumList as $attribute => $values) {
                        $this->enumData[$attribute . 'List'] = $values;
                        $this->enumData[$attribute . 'Value'] = $this->owner->$attribute;
                        $valueName = isset($values[$this->owner->$attribute]) ? $values[$this->owner->$attribute] : $this->owner->$attribute;
                        $this->enumData[$attribute . 'Name'] = $valueName;
                    }
                }
            }
        }
    }
1041229
private function validateAttributes(iterable $attributes): self
    {
        // execute start(s)
        $this->executeStarts($this->getSerializer()::readRuleStartIndexes($this->getRuleIndexes()));

        foreach ($attributes as $name => $value) {
            if (($index = $this->getAttributeIndex($name)) !== null) {
                $this->executeBlock($value, $index);
            } else {
                $this->getErrorAggregator()->add(
                    new Error($name, $value, ErrorCodes::INVALID_VALUE, Messages::INVALID_VALUE, [])
                );
            }
        }

        // execute end(s)
        $this->executeEnds($this->getSerializer()::readRuleEndIndexes($this->getRuleIndexes()));

        return $this;
    }
381350
private function validateUserInputs($attributes, $eventTags = null)
    {
        if (!is_null($attributes) && !Validator::areAttributesValid($attributes)) {
            $this->_logger->log(Logger::ERROR, 'Provided attributes are in an invalid format.');
            $this->_errorHandler->handleError(
                new InvalidAttributeException('Provided attributes are in an invalid format.')
            );
            return false;
        }

        if (!is_null($eventTags)) {
            if (!Validator::areEventTagsValid($eventTags)) {
                $this->_logger->log(Logger::ERROR, 'Provided event tags are in an invalid format.');
                $this->_errorHandler->handleError(
                    new InvalidEventTagException('Provided event tags are in an invalid format.')
                );
                return false;
            }
        }

        return true;
    }
744800
public function createInput(array $attributes = [])
    {
        $field = new Form\Elements\Input();

        if (count($attributes)) {
            foreach ($attributes as $name => $value) {
                $field->attributes->addAttribute($name, $value);

                if ($name === 'name') {
                    $this->entity->setEntityName('input-' . $value);

                    if ( ! array_key_exists('id', $attributes)) {
                        $field->attributes->setAttributeId('input-' . $value);
                    }
                }
            }
        }

        return $this->input = $field;
    }
1152096
public function attributeValidationException(AbstractAttribute $attribute, ValidationException $e)
    {
        $attrException = new AttributeValidationException($e->getMessage());
        $attrException->addError($attribute->getName(), $e->getMessage());

        return $attrException;
    }
1188766
public function newFromBuilder($attributes = array(), $connection = null)
    {
        $model = parent::newFromBuilder($attributes, $connection);
        $model->inspectJsonColumns();
        $model->addHintedAttributes();

        return $model;
    }
222911
private static function validateAttributes($model, $name, &$attributes)
    {
        // Should be an array.
        if (!is_array($attributes)) {
            $attributes = [$attributes];
        }

        // Is empty, use the name of the table + name.
        if (empty($attributes)) {
            $attributes = [sprintf('%s.%s', $model->getTable(), $name)];
        }

        // Check each of the attribute values.
        // Convert any prepended with a curly to an expression.
        foreach ($attributes as &$value) {
            if (substr($value, 0, 1) === '#' || substr($value, 0, 1) === '{') {
                $value = new Expression(substr($value, 1));
            }
        }
    }
701452
public function createButton($label, array $attributes = [])
    {
        $button = new Components\Form\Elements\Button($label);

        if ( ! array_key_exists('class', $attributes)) {
            $button->attributes->addAttributeClass(['btn', 'my-2', 'my-sm-0']);
        }

        if (count($attributes)) {
            foreach ($attributes as $name => $value) {
                $button->attributes->addAttribute($name, $value);
            }
        }

        $this->childNodes->push($button);

        return $this->childNodes->last();
    }