sfDateValidator: Compare with current date part 2

April 6, 2007

Today Markus posted a great idea in the comments. Instead of just “now”, the sfDateValidator could accept all values that the strtotime function accepts.

So, here it is. All the values that the strtotime function accepts are now supported.
For example, if you want to check if a date isn’t greater than one week, just go with:

 

fields:
  date:
    required:
      msg: This field is required
    sfDateValidator:
      compare: "+1 week"
      operator: "<="

Just make sure you don’t name your form fields “now”, “yesterday” or “tomorrow” ;-)
Thank you Markus for the suggestion.

Advertisements

One Response to “sfDateValidator: Compare with current date part 2”

  1. symfoniac Says:

    For the next version i think about a range parameter.
    For example:

    date:
    sfDateValidator:
    range_start: “now”
    range_end: “+1 week”

    would check if the date is in that range.
    Optionally a “range_option: not” which would check if the date IS NOT in the range.

    What do you think about this? Other ideas?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: