{"id":22763067,"url":"https://github.com/mgrechanik/yii2-activefield-additional-error","last_synced_at":"2026-02-14T04:54:26.377Z","repository":{"id":267448350,"uuid":"901270937","full_name":"mgrechanik/yii2-activefield-additional-error","owner":"mgrechanik","description":"Adding special span to activefield with bootstrap error class .is-invalid to desired place of field template","archived":false,"fork":false,"pushed_at":"2024-12-10T12:26:36.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T20:51:30.157Z","etag":null,"topics":["activefield","activeform","bootstrap4","bootstrap5","yii2"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mgrechanik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-10T10:58:04.000Z","updated_at":"2024-12-10T12:26:21.000Z","dependencies_parsed_at":"2024-12-10T12:43:38.510Z","dependency_job_id":null,"html_url":"https://github.com/mgrechanik/yii2-activefield-additional-error","commit_stats":null,"previous_names":["mgrechanik/yii2-activefield-additional-error"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgrechanik%2Fyii2-activefield-additional-error","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgrechanik%2Fyii2-activefield-additional-error/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgrechanik%2Fyii2-activefield-additional-error/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgrechanik%2Fyii2-activefield-additional-error/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mgrechanik","download_url":"https://codeload.github.com/mgrechanik/yii2-activefield-additional-error/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248661006,"owners_count":21141381,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activefield","activeform","bootstrap4","bootstrap5","yii2"],"created_at":"2024-12-11T11:06:37.841Z","updated_at":"2026-02-14T04:54:21.355Z","avatar_url":"https://github.com/mgrechanik.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Additional span with error class for ActiveField\n\n## What is it about? \u003cspan id=\"demo\"\u003e\u003c/span\u003e\n\nBootstrap 4 and 5 are expecting ```html``` like this to decorate validation error:\n\n```html\n\u003cinput type=\"text\" id=\"eventform-datetime\" class=\"form-control is-invalid\" name=\"EventForm[datetime]\" aria-required=\"true\"\u003e\n\u003cdiv class=\"invalid-feedback\"\u003eError message\u003c/div\u003e\n```\n\nElement with ```div.invalid-feedback``` is supposed to be on the same level with your ```input.is-invalid```.\n\nBut sometimes when we are using any widgets or custom template we get html like this:\n\n```html\n\u003cdiv class=\"some-plugin-wrapper\"\u003e\n  \u003cinput type=\"text\" id=\"eventform-datetime\" class=\"form-control is-invalid\" name=\"EventForm[datetime]\" aria-required=\"true\"\u003e\n\u003c/div\u003e  \n\u003cdiv class=\"invalid-feedback\"\u003eError message\u003c/div\u003e\n```\n, so **our error message is not shown**.\n\nOf cource you can make ```div.invalid-feedback``` visible by css for this page.\n\nBut if that does not suit you, this library propose another solution.\n\nWe are adding special ```\u003cspan\u003e``` to a field template right before ```{error}``` part. And we **synchronize** this ```\u003cspan\u003e``` with the **input field** so it gets ```.is-invalid``` class when **input** does \n\n\n## Installing \u003cspan id=\"installing\"\u003e\u003c/span\u003e\n\n#### Installing through composer::\n\nThe preferred way to install this library is through composer.\n\nEither run\n```\ncomposer require --prefer-dist mgrechanik/yii2-activefield-additional-error \n```\n\nor add\n```\n\"mgrechanik/yii2-activefield-additional-error \" : \"~1.0.0\"\n```\nto the require section of your `composer.json`.\n\n## How to use  \u003cspan id=\"use\"\u003e\u003c/span\u003e \n\nin your ```view``` file, say it is ```_form.php```\n\n```php\nuse mgrechanik\\additionalerror\\AdditionalErrorBehavior;\n\n\u003cdiv class=\"event-form-form\"\u003e\n\n    \u003c?php $form = ActiveForm::begin([\n            'id' =\u003e 'event-create-form',\n            // Adding behavior\n            'as adderror' =\u003e [\n                'class' =\u003e AdditionalErrorBehavior::class,\n            ]\n    ]); ?\u003e\n\n    \u003c?= $form-\u003efield($model, 'datetime', [\n            // Adding this hidden span before error block \n            'template' =\u003e \"{label}\\n{input}\\n{hint}\\n\" . $form-\u003egetAdditionalErrorSpan($model, 'datetime') . \"\\n{error}\"\n    ])-\u003ehint('Some hint')\n      -\u003ewidget(/* Some complicated widget creates a wrapper for the {input} part... */)\n```\n\nIt will work for both server and client side.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgrechanik%2Fyii2-activefield-additional-error","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgrechanik%2Fyii2-activefield-additional-error","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgrechanik%2Fyii2-activefield-additional-error/lists"}