bramstroker / zf2-form

ZF2 module for extending forms with live clientside validation without need to write js validation code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rules for array based form elements as DateSelect

cbichis opened this issue · comments

Hi,

I think it would be interesting to have a way to use Stroker Form for cases of elements based on an array as DateSelect:

date[year]
date[month]
date[day]

With date select a user will always select a valid date, so I don't see why there is a need to validate this client side. Could you elaborate?

Yes, it could be at least 2 cases for which is needed to validate the input:

  1. If no date is selected at all (but the date is required)
  2. when just some of the data part is set (let's suppose only year has been selected, not also month and day)

I am unsure how the rule should work taking into consideration that there are multiple fields involved, you know better :)

@cbichis I am also not sure how to implement something like this in a generic way, because both StrokerForm and jquery validate library expects a validator to be attached to one given element.
Could you share your ZF2 snippet how you have coded the form fields and inputfilter right now, than we can think about a possible solution.
However I think a feature like this will be out of scope for this module. You can just create your own custom jquery validate rule and write some javascript code to get the validation you want.

I have 2 dummy cases DateSelect validator can be useful:

  1. To check if the data entered is correct (including if all the subfields - date, month, year has been selected)
  2. For a validator like "you have 18 years" ?