ZenValidatorConstraint::applyParsley PHP Method

applyParsley() public method

Sets the html attributes required for frontend validation Subclasses should call parent::applyParsley
public applyParsley ( ) : void
return void
    public function applyParsley()
    {
        if (!$this->field) {
            user_error("A constrained Field does not exist on the FieldSet, check you have the right field name for your ZenValidatorConstraint.", E_USER_ERROR);
        }
        $this->parsleyApplied = true;
        if ($this->customMessage) {
            $this->field->setAttribute(sprintf('data-parsley-%s-message', $this->getConstraintName()), $this->customMessage);
        }
        // CheckboxSetField might not have a unique name, so set parsley-multiple attribute
        if (get_class($this->field) === 'CheckboxSetField') {
            $this->field->setAttribute('data-parsley-multiple', $this->field->getName());
        }
    }

Usage Example

 public function applyParsley()
 {
     parent::applyParsley();
     $this->field->setAttribute('data-parsley-dateiso', 'true');
 }