-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #3220 Allow to render ChoiceField values as badges (javieregu…
…iluz) This PR was squashed before being merged into the 3.0.x-dev branch. Discussion ---------- Allow to render ChoiceField values as badges This was one of the main features in my TODO list before the EA3 release. The new `renderAsBadges()` method is very flexible, as explained in its PHPdoc: ``` /** * Possible values of $boolArrayOrCallable: * * true: values are displayed as a normal badge * * false: values are displayed as regular text * * array: keys are the field value and values are the badge type * * callable: the FieldDto is passed as argument and return value is the badge type * * Possible badge types: 'success', 'warning', 'danger', 'info', 'primary', 'secondary', 'light', 'dark' */ public function renderAsBadges($boolArrayOrCallable = true): self; ``` This is how badges look in the index page: ![badges-index](https://user-images.githubusercontent.com/73419/81980767-7e035b80-962f-11ea-8fd0-01e68ee8c7b6.png) And in the detail page: ![badges-detail](https://user-images.githubusercontent.com/73419/81980778-8196e280-962f-11ea-9f7e-ba9ece7324a4.png) Commits ------- 0fab91b Allow to render ChoiceField values as badges
- Loading branch information
Showing
12 changed files
with
156 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Badges | ||
// ---------------------------------------------------------------------------- | ||
|
||
.badge + .badge { | ||
margin-left: 8px; | ||
} | ||
|
||
.badge.badge-pill { | ||
border-radius: 20px; | ||
font-size: var(--font-size-xs); | ||
line-height: 16px; | ||
padding: 2px 8px; | ||
} | ||
|
||
.badge.badge-success { | ||
background-color: var(--green-100); | ||
color: var(--text-green-600); | ||
} | ||
.badge.badge-warning { | ||
background-color: var(--yellow-100); | ||
color: var(--text-yellow-600); | ||
} | ||
.badge.badge-danger { | ||
background-color: var(--red-100); | ||
color: var(--text-red-600); | ||
} | ||
.badge.badge-info { | ||
background-color: var(--blue-100); | ||
color: var(--text-blue-600); | ||
} | ||
.badge.badge-primary { | ||
background-color: var(--indigo-100); | ||
color: var(--text-indigo-600); | ||
} | ||
.badge.badge-secondary { | ||
background-color: var(--gray-300); | ||
color: var(--text-color); | ||
} | ||
.badge.badge-light { | ||
background-color: var(--gray-50); | ||
color: var(--text-color); | ||
} | ||
.badge.badge-dark { | ||
background-color: var(--gray-900); | ||
color: var(--gray-50); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...sources/views/crud/field/select.html.twig → ...sources/views/crud/field/choice.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | ||
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} | ||
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} | ||
{{ field.formattedValue }} | ||
{{ field.formattedValue|raw }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.