From c039e4d465cfe055fd54a57fb41db5a1b225309a Mon Sep 17 00:00:00 2001 From: Davide Bellini Date: Tue, 17 Mar 2020 16:02:06 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Fieldset:=20The=20=E2=80=9Cfields=E2=80=9D?= =?UTF-8?q?=20key=20must=20be=20specified=20for=20some=20validation=20rule?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/collections/docs/fieldsets.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/content/collections/docs/fieldsets.md b/content/collections/docs/fieldsets.md index 11e844ce..46153f03 100644 --- a/content/collections/docs/fieldsets.md +++ b/content/collections/docs/fieldsets.md @@ -70,6 +70,22 @@ fields: This would make the field required, ensure only alpha-numeric characters and dashes are used, and that the text is between 5 and 10 characters long. +If you using a validation rule that require a field name to be specified (like _required_if_, _same_, ...), **remember** to prepend `fields.` to the field name. + +For example: + +``` .language-yaml +fields: + type: + options: + option_1: 'Option 1' + option_2: 'Option 2' + type: radio + something: + type: text + validate: required_if:fields.type,option_1 +``` + Note that not _every_ validation rule would be usable in Statamic. For instance, the database rules (exists, unique, etc) would not apply since we do not use a database. ## Sections [Since 2.9.0] {#sections} @@ -210,7 +226,7 @@ show_when: that_field: cheeseburger ``` -You can use "OR" rules by prepending fields with `or_`. +You can use "OR" rules by prepending fields with `or_`. The following says: "Show when `this_field` is `bacon` OR `that_field` is `cheeseburger`" ``` .language-yaml @@ -219,7 +235,7 @@ show_when: or_that_field: cheeseburger ``` -You may specify multiple values for a single field by using an array for the value. +You may specify multiple values for a single field by using an array for the value. The following says: "Show when `this_field` is one of `bacon`, `eggs`, or `hash browns`" ``` .language-yaml From d55459870ad9eaacae59c43e87495136ac003cc9 Mon Sep 17 00:00:00 2001 From: Davide Bellini Date: Tue, 17 Mar 2020 16:09:55 +0100 Subject: [PATCH 2/2] Restored trailing whitespaces --- content/collections/docs/fieldsets.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/collections/docs/fieldsets.md b/content/collections/docs/fieldsets.md index 46153f03..7890ca85 100644 --- a/content/collections/docs/fieldsets.md +++ b/content/collections/docs/fieldsets.md @@ -226,7 +226,7 @@ show_when: that_field: cheeseburger ``` -You can use "OR" rules by prepending fields with `or_`. +You can use "OR" rules by prepending fields with `or_`. The following says: "Show when `this_field` is `bacon` OR `that_field` is `cheeseburger`" ``` .language-yaml @@ -235,7 +235,7 @@ show_when: or_that_field: cheeseburger ``` -You may specify multiple values for a single field by using an array for the value. +You may specify multiple values for a single field by using an array for the value. The following says: "Show when `this_field` is one of `bacon`, `eggs`, or `hash browns`" ``` .language-yaml