Jump to:

2002 Posts in 1422 Topics by 616 members

Form Questions

SilverStripe Forums » Form Questions » Validate Dates

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 197 Views
  • cumquat
    Avatar
    Community Member
    191 Posts

    Validate Dates Link to this post

    Ok got an issue, i'm trying to work out how to validate a form/datobject, i have a start date for a task and an end date for the task, what i want to do is on the edit task form if the FinDate field is populated that it checks that the value is not less than the StartDate.

    I've tried,

    if(isset($_POST['FinDate'])) {
              if($_POST['FinDate'] < $_POST['StartDate']) {
       $form->addErrorMessage('FinDate', 'End Date cannot be fore start date', 'bad');
       return $this->redirectBack();
    }
          }

    but this just keeps firing when no date is added and if a date is added it doesn't validate.

    Any help or pointers much appreciated.

    Mick

    197 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.