getCurrentPageIndex will return null if index is 0
Description See https://github.com/verbb/formie/blob/8f1a58c28b3c8166756d61d6d0393af235d68978/src/elements/Form.php#L815:L817
If you are on the first page it will return null because when the $index is 0 it will be seen as false.
Is that a problem? The correct behaviour should be that it's null when the index has yet to be set. 0 would be returning if say you submitted the form and it failed validation (returning you to the first page), or if you navigate back to the first page.
Happy to amend, but would like to hear your use-case. And also the Craft/Formie version you're on.
Yeah it's kinda nitpicky. I'm on Craft Pro 3.7.44 and Formie 1.6.1.
I'm using this for a custom validation where I have 10 fields on the second page where at least one has to be filled in. When I don't add this page check the validation error will already be shown on the first visit, before the submit of the second page. I didn't needed the first page but was confused why it returned null.
All good, just wanted to check! I'll have that fixed up, but might be in Formie v2 with some other changes related to pages and active states.
Fixed for the next release. To get this early, change your verbb/formie requirement in composer.json to:
"require": {
"verbb/formie": "dev-craft-4 as 2.0.9",
"...": "..."
}
Then run composer update.
Fixed in 2.0.10