Skip to content

Commit

Permalink
Merge pull request #125 from craftpulse/v5-develop
Browse files Browse the repository at this point in the history
chore: resolve merge conflicts
  • Loading branch information
cookie10codes authored Apr 15, 2024
2 parents 52e9d43 + e4ffbeb commit 1c6137f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 5.0.1 - 2024-03-08
## 5.0.2 - 2024-03-08
### Fixed
- Fixed the default fetch if the default isn't the first one in the config list

## 5.0.1 - 2024-04-15
### Fixed
- Fixed the bug when default color isn't the first in array #124

## 5.0.0 - 2024-03-02
### Added
- Provided support for Craft 5 (tanks to [@marknotton-yello](https://github.com/marknotton-yello))
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "craftpulse/craft-colour-swatches",
"description": "Let clients choose from a predefined set of colours and utilise associated colour codes and class names in your templates.",
"type": "craft-plugin",
"version": "5.0.1",
"version": "5.0.2",
"keywords": [
"craft",
"cms",
Expand Down
8 changes: 2 additions & 6 deletions src/fields/ColourSwatches.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,8 @@ public function normalizeValue(mixed $value, ?ElementInterface $element = null):
// if default is set --> return default
$default = array_filter($this->options, function($option) {return $option['default'] == 1;});

if (!is_null($default) && count($default) > 0) {
try {
return new ColourSwatchesModel(Json::encode(current($default)));
} catch(\ErrorException) {
Craft::error("There's no default colour defined");
}
if (is_array($default) && count($default) > 0) {
return new ColourSwatchesModel(Json::encode(array_values($default)[0]));
}

// if no default is set --> return null
Expand Down

0 comments on commit 1c6137f

Please sign in to comment.