This repository was archived by the owner on Jan 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 136
ZF3 Using Explode with InArray validator as child breaks validation messages format #230
Copy link
Copy link
Open
Description
I am using the following array notation in my form creation for a single select element:
'validators' => [
[
'name' => 'Explode',
'options' => [
'validator' => [
'name'=>'InArray',
'options'=>[
'haystack'=>[1,2],
'message'=> 'Invalid status'
]
]
]
],
]
When I submit an invalid option, I get this from $form->getMessages()
:
array (size=3)
'status' =>
array (size=2)
'notInArray' => string 'The input was not found in the haystack' (length=39)
0 =>
array (size=1)
'notInArray' => string 'Invalid status' (length=14)
Without the Explode layer in the validators,
[
'name'=>'InArray',
'options'=>[
'haystack'=>[1,2],
'message'=>'Invalid status'
]
],
$form->getMessages()
reports this when invalid:
array (size=3)
'status' =>
array (size=1)
'notInArray' => string 'Invalid status' (length=14)
Since Explode does not acknowledge a message option and when I set disable_inarray_validator
to true I still get:
'status' =>
array (size=2)
'notInArray' => string 'The input was not found in the haystack' (length=39)
0 =>
array (size=1)
'notInArray' => string 'Invalid status' (length=14)
What I am expecting to get is:
'status' =>
array (size=1)
'notInArray' =>
array (size=1)
0 => string 'Invalid status' (length=14)
From what I can tell, Explode is a utility to help process validators rather than being an actual validator. But in using it, it breaks validation messages so my standard code for processing form validation messages does not work.
Metadata
Metadata
Assignees
Labels
No labels