PHPackages                             mgrechanik/yii2-activefield-additional-error - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. mgrechanik/yii2-activefield-additional-error

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

mgrechanik/yii2-activefield-additional-error
============================================

Adding special span to activefield with bootstrap error class .is-invalid to desired place of field template

1.0.1(1y ago)081BSD-3-ClausePHPPHP &gt;=7.3.0

Since Dec 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mgrechanik/yii2-activefield-additional-error)[ Packagist](https://packagist.org/packages/mgrechanik/yii2-activefield-additional-error)[ RSS](/packages/mgrechanik-yii2-activefield-additional-error/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Additional span with error class for ActiveField
================================================

[](#additional-span-with-error-class-for-activefield)

What is it about?
------------------

[](#what-is-it-about-)

Bootstrap 4 and 5 are expecting `html` like this to decorate validation error:

```

Error message
```

Element with `div.invalid-feedback` is supposed to be on the same level with your `input.is-invalid`.

But sometimes when we are using any widgets or custom template we get html like this:

```

Error message
```

, so **our error message is not shown**.

Of cource you can make `div.invalid-feedback` visible by css for this page.

But if that does not suit you, this library propose another solution.

We are adding special `` to a field template right before `{error}` part. And we **synchronize** this `` with the **input field** so it gets `.is-invalid` class when **input** does

Installing
-----------

[](#installing-)

#### Installing through composer::

[](#installing-through-composer)

The preferred way to install this library is through composer.

Either run

```
composer require --prefer-dist mgrechanik/yii2-activefield-additional-error

```

or add

```
"mgrechanik/yii2-activefield-additional-error " : "~1.0.0"

```

to the require section of your `composer.json`.

How to use
-----------

[](#how-to-use--)

in your `view` file, say it is `_form.php`

```
use mgrechanik\additionalerror\AdditionalErrorBehavior;
