mirror of
https://github.com/getgrav/grav.git
synced 2026-02-22 06:28:03 +01:00
Added support for custom form field options validation with validate: options: key|ignore
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
* Added method `Pages::referrerRoute()` to get the referrer route and language
|
||||
* Added true unique `Utils::uniqueId()` / `{{ unique_id() }}` utilities with length, prefix, and suffix support
|
||||
* Added `UserObject::isMyself()` method to check if flex user is currently logged in
|
||||
* Added support for custom form field options validation with `validate: options: key|ignore`
|
||||
2. [](#improved)
|
||||
* Replaced GPL `SVG-Sanitizer` with MIT licensed `DOM-Sanitizer`
|
||||
* `Uri::referrer()` now accepts third parameter, if set to `true`, it returns route without base or language code [#3411](https://github.com/getgrav/grav/issues/3411)
|
||||
|
||||
@@ -781,14 +781,22 @@ class Validation
|
||||
}
|
||||
|
||||
// If creating new values is allowed, no further checks are needed.
|
||||
if (!empty($field['selectize']['create'])) {
|
||||
$validateOptions = $field['validate']['options'] ?? null;
|
||||
if (!empty($field['selectize']['create']) || $validateOptions === 'ignore') {
|
||||
return true;
|
||||
}
|
||||
|
||||
$options = $field['options'] ?? [];
|
||||
$use = $field['use'] ?? 'values';
|
||||
|
||||
if (empty($field['selectize']) || empty($field['multiple'])) {
|
||||
if ($validateOptions) {
|
||||
// Use custom options structure.
|
||||
foreach ($options as &$option) {
|
||||
$option = $option[$validateOptions] ?? null;
|
||||
}
|
||||
unset($option);
|
||||
$options = array_values($options);
|
||||
} elseif (empty($field['selectize']) || empty($field['multiple'])) {
|
||||
$options = array_keys($options);
|
||||
}
|
||||
if ($use === 'keys') {
|
||||
|
||||
Reference in New Issue
Block a user