/** * @param AbstractField|Group|Fieldset $element * * @return void */ private function addErrorClass($element) { if ($element instanceof Group || $element instanceof Fieldset) { foreach ($element->getFields() as $field) { if ($element instanceof Group || $element instanceof Fieldset) { $this->addErrorClass($field); } elseif ($field->isRequired()) { $field->addClass('has-error'); } } } elseif ($element->isRequired()) { $element->addClass('has-error'); } }
/** * {@inheritdoc} */ public function __construct(string $label = null) { parent::__construct($label); $this->addClass('form-group cawa-fields-group'); $this->container->addClass('row'); }
/** * @param AbstractField|Group|Fieldset $element * @param mixed $userInput * * @return array */ private function validateValue($element, $userInput) : array { $valid = true; $value = null; $typedValue = null; if ($element->isRequired() && is_null($userInput)) { $valid = false; } if ($element->getPrimitiveType() && !is_null($userInput)) { $typedValue = $this->validateType($userInput, $element->getPrimitiveType()); if (is_null($typedValue)) { $valid = false; } else { $value = $typedValue; } } else { $value = $userInput; } if (method_exists($element, 'isValid') && $valid == true && $element->getValue()) { $valid = $element->isValid(); } if (!$valid) { $value = null; } return [$valid, $value, $typedValue]; }