I tried to validate fields within a structure like this:
title: Booking Manager
pages: false
fields:
title:
label: Title
type: text
required: true
description:
label: Description
type: textarea
products:
label: Products
type: structure
entry: >
<h1>{{ title }}</h1>
<p><b>Description:</b> {{ description }}</p>
<p><b>Price:</b> {{ price }}</p>
fields:
title:
label: Title
type: text
required: true
description:
label: Description
type: textarea
required: true
price:
label: Price
type: text
validate:
num
help: Please type in a number
Validation works fine outside of the products structure (not included in this example but I tried it with “validate: num”), the price part is where I get problems. When entering and saving a text here, it does not give me an error message. When editing the just created structure though, I get an error message.
Shouldn’t there be an immediate error message when trying to enter a alpha text into a numerical validated field?
Cheers
Jan
PS: This is the same for every validation tried inside a structure field
Hm, for me it doesn’t work outside of a structure field either in the latest Kirby version while it does in an older one. You could just use a number field instead of a text field, where the validation is already built in.
Nope for me it doesn’t… For example I trie entering 123.123 and a message appears “Please enter a valid value. The two nearest valid values are 123 and 124”
Ok that’s too bad, maybe it will be fixed in the next version then…
The funny part is, that I get an error message when editing the structure right away (before saving the whole thing).
Thanks for the worries though!
I just tested (Kirby/Panel 2.2.3) with a text field inside a structure field that validates using a regular expression (match) and by using the min and max values. It all works just fine for me and the rules prevent me from saving the structure item.
I’m marking this as solved. If anyone continues to have problems with validation, don’t hesitate to post here and I will reopen.