sfDateValidator: Compare with current date

April 5, 2007

Yesterday Hobbles wrote a comment asking me how to easily compare a entered date with the current date (And even posted a solution for this today) . I must agree that this feature is very useful, so i implemented it into the validator. Get the updated version here.

Usage example:

 

fields:
  date:
    required:
      msg: This field is required
    sfDateValidator:
      compare: now
      operator: ">"

This would check if the date, entered in the form field date, is in the future.
Thanks again to Hobbles for this great idea.

Advertisements

4 Responses to “sfDateValidator: Compare with current date”

  1. Markus Says:

    Hi,

    maybe all types of strtotime parameters should be possible..?

    e.g.
    “last Monday”
    “+1 week 2 days 4 hours 2 seconds”
    etc..

    see
    http://php.net/strtotime

    Bye,
    Markus

  2. symfoniac Says:

    Done! ;)

  3. Hobbles Says:

    Great to see that you even expanded my idea! I will update my older validator with your fixed one.

    Thanks!

  4. Diego Drigani Says:

    Hi, one cuestion, why dont use the i18n format for the validator? For some reason in particular?


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: