Skip to content

Commit

Permalink
Added checkbox-style support for switch field
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Feb 15, 2018
1 parent 84a2a08 commit 550468a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
1. [](#improved)
* Better `Page.collection()` filtering support including ability to have non-published pages in collections
* Stopped Chrome from auto-completing admin user profile form [#1847](https://github.com/getgrav/grav/issues/1847)
* Support for empty `switch` field like a `checkbox`
1. [](#bugfix)
* Properly validate YAML blueprint fields so admin can save as proper YAML now [addresses many issues]
* Fixed OpenGraph metatags so only Twitter uses `name=`, and all others use `property=` [#1849](https://github.com/getgrav/grav/issues/1849)
Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/Data/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function validate($value, array $field)
$method = 'type'.strtr($type, '-', '_');

// If value isn't required, we will stop validation if empty value is given.
if ((empty($validate['required']) || (isset($validate['required']) && $validate['required'] !== true)) && ($value === null || $value === '' || ($field['type'] === 'checkbox' && $value == false))) {
if ((empty($validate['required']) || (isset($validate['required']) && $validate['required'] !== true)) && ($value === null || $value === '' || (($field['type'] === 'checkbox' || $field['type'] === 'switch') && $value == false))) {
return $messages;
}

Expand Down

0 comments on commit 550468a

Please sign in to comment.