From 4063a438e6f03650de9e90e014420756bc581fca Mon Sep 17 00:00:00 2001 From: Simon Karlen Date: Tue, 3 Aug 2021 10:41:30 +0200 Subject: [PATCH] added Floating label to docs and fixed template in field --- docs/guide-de/migrating-yii2-bootstrap.md | 3 +++ docs/guide-ja/migrating-yii2-bootstrap.md | 2 ++ docs/guide/migrating-yii2-bootstrap.md | 3 +++ src/ActiveField.php | 3 +++ 4 files changed, 11 insertions(+) diff --git a/docs/guide-de/migrating-yii2-bootstrap.md b/docs/guide-de/migrating-yii2-bootstrap.md index 388cc10..91a17d3 100644 --- a/docs/guide-de/migrating-yii2-bootstrap.md +++ b/docs/guide-de/migrating-yii2-bootstrap.md @@ -16,6 +16,9 @@ Die grössten Änderungen finden Sie hier zusammengefasst: ### ActiveForm +Es gibt eine neue Konstante [[yii\bootstrap5\ActiveForm::LAYOUT_FLOATING]]. Sie repräsentiert ein neues +[neues Formular-Layout](https://getbootstrap.com/docs/5.0/forms/floating-labels/) in Bootstrap 5. + ### Breadcrumbs ### ButtonDropdown diff --git a/docs/guide-ja/migrating-yii2-bootstrap.md b/docs/guide-ja/migrating-yii2-bootstrap.md index 7bb59a4..04e7bc2 100644 --- a/docs/guide-ja/migrating-yii2-bootstrap.md +++ b/docs/guide-ja/migrating-yii2-bootstrap.md @@ -16,6 +16,8 @@ yii2-bootstrap5 は、Bootstrap 4 から Bootstrap 5 への移行ガイドに従 ### ActiveForm +新しい定数[[yii\bootstrap5\ActiveForm::LAYOUT_FLOATING]]があります。 Bootstrap5で導入された[新しいフォームレイアウト](https://getbootstrap.com/docs/5.0/forms/floating-labels/)です。 + ### Breadcrumbs ### ButtonDropdown diff --git a/docs/guide/migrating-yii2-bootstrap.md b/docs/guide/migrating-yii2-bootstrap.md index 47bd135..7275908 100644 --- a/docs/guide/migrating-yii2-bootstrap.md +++ b/docs/guide/migrating-yii2-bootstrap.md @@ -16,6 +16,9 @@ The most notable changes are summarized below: ### ActiveForm +There is a new constant [[yii\bootstrap5\ActiveForm::LAYOUT_FLOATING]]. It's a +[new form layout](https://getbootstrap.com/docs/5.0/forms/floating-labels/) introduced in Bootstrap 5. + ### Breadcrumbs ### ButtonDropdown diff --git a/src/ActiveField.php b/src/ActiveField.php index 673c75a..75cb1b0 100644 --- a/src/ActiveField.php +++ b/src/ActiveField.php @@ -518,6 +518,9 @@ class ActiveField extends \yii\widgets\ActiveField $config['enableError'] = false; Html::addCssClass($config['labelOptions'], ['screenreader' => 'visually-hidden']); + } elseif ($layout === ActiveForm::LAYOUT_FLOATING) { + $config['template'] = "{input}\n{label}\n{error}\n{hint}"; + Html::addCssClass($config['options'], ['layout' => 'form-floating mt-3']); } return $config;