protected function addErrorClass()
    {
        $errors = $this->parent->getRequest()->session()->get('errors');
        $errorBag = $this->parent->getErrorBag();

        if ($errors && $errors->hasBag($errorBag) && $errors->getBag($errorBag)->has($this->getNameKey())) {
            $fieldErrorClass = $this->getConfig('defaults.field_error_class');
            $fieldClass = $this->getOption('attr.class');

            if ($fieldErrorClass && !str_contains($fieldClass, $fieldErrorClass)) {
                $fieldClass .= ' ' . $fieldErrorClass;
                $this->setOption('attr.class', $fieldClass);
            }

            $wrapperErrorClass = $this->getConfig('defaults.wrapper_error_class');
            $wrapperClass = $this->getOption('wrapper.class');

            if ($wrapperErrorClass && $this->getOption('wrapper') && !str_contains($wrapperClass, $wrapperErrorClass)) {
                $wrapperClass .= ' ' . $wrapperErrorClass;
                $this->setOption('wrapper.class', $wrapperClass);
            }
        }
    }
protected function addErrorClass()
    {
        $errors = $this->parent->getRequest()->session()->get('errors');
        $errorBag = $this->parent->getErrorBag();

        if ($errors && $errors->hasBag($errorBag) && $errors->getBag($errorBag)->has($this->getNameKey())) {
            $fieldErrorClass = $this->getConfig('defaults.field_error_class');
            $fieldClass = $this->getOption('attr.class');

            if ($fieldErrorClass && !str_contains($fieldClass, $fieldErrorClass)) {
                $fieldClass .= ' ' . $fieldErrorClass;
                $this->setOption('attr.class', $fieldClass);
            }

            $wrapperErrorClass = $this->getConfig('defaults.wrapper_error_class');
            $wrapperClass = $this->getOption('wrapper.class');

            if ($wrapperErrorClass && $this->getOption('wrapper') && !str_contains($wrapperClass, $wrapperErrorClass)) {
                $wrapperClass .= ' ' . $wrapperErrorClass;
                $this->setOption('wrapper.class', $wrapperClass);
            }
        }
    }
protected function addErrorClass ( ) { $ errors = $ this -> parent -> getRequest ( ) -> session ( ) -> get ( 'errors' ) ; $ errorBag = $ this -> parent -> getErrorBag ( ) ; if ( $ errors && $ errors -> hasBag ( $ errorBag ) && $ errors -> getBag ( $ errorBag ) -> has ( $ this -> getNameKey ( ) ) ) { $ fieldErrorClass = $ this -> getConfig ( 'defaults.field_error_class' ) ; $ fieldClass = $ this -> getOption ( 'attr.class' ) ; if ( $ fieldErrorClass && ! str_contains ( $ fieldClass , $ fieldErrorClass ) ) { $ fieldClass .= ' ' . $ fieldErrorClass ; $ this -> setOption ( 'attr.class' , $ fieldClass ) ; } $ wrapperErrorClass = $ this -> getConfig ( 'defaults.wrapper_error_class' ) ; $ wrapperClass = $ this -> getOption ( 'wrapper.class' ) ; if ( $ wrapperErrorClass && $ this -> getOption ( 'wrapper' ) && ! str_contains ( $ wrapperClass , $ wrapperErrorClass ) ) { $ wrapperClass .= ' ' . $ wrapperErrorClass ; $ this -> setOption ( 'wrapper.class' , $ wrapperClass ) ; } } }
Add error class to wrapper if validation errors exist.

@return void
Add error class to wrapper if validation errors exist .