File: D:/HostingSpaces/SBogers10/ilysium.komma.pro/wwwroot/lib/form/types/field_type_date.class.php
<?php
/**
* form_type_date.class.php
* Created by Komma Mediadesign.
* Author: mike
* Date: 4/3/13
*/
class Field_Type_Date extends Form_Field
{
public function construct(){}
public function generate()
{
// Text area
$err = isset($_SESSION[$this->formName . '_errors'][$this->name]);
$output = '';
$output .= '<div class="input_holder';
if($err) $output .= ' error';
$output .= '">';
if($err) $output .= '<span class="error">' . $_SESSION[$this->formName . '_errors'][$this->name] . '</span>';
$output .= '<label for="' . $this->name .'">' . $this->label . '</label>
<input type="text" name="' . $this->name . '" id="' . $this->name . '" data-label="' . $this->placeholder . '" value="' . $this->value .'" class="datepicker"/>';
if( ! strstr($_SERVER['HTTP_USER_AGENT'],'iPhone')) $output .= '<span class="placeholder">' . $this->placeholder . '</span>';
$output .= '</div>';
return $output;
}
/*
* Check if date really exists
*/
public function validate()
{
// Get values
$input = $_POST[$this->name];
$_SESSION[$this->formName]['data'][$this->name] = $input;
//check if input is a valid date
$temp = explode('-',$input);
if(count($temp) >= 3)
{
$day = (int) $temp[0];
$month = (int) $temp[1];
$year = (int) $temp[2];
if(checkdate($month,$day,$year))
{
return true;
}
}
// set error message
//$this->errors = 'Dit is geen geldige datum';
//return false; DONT VALIDATE
return true;
}
}