public static function set_date_format($format) { switch ($format) { case "mdy": self::$dateFormat = "mm/dd/yy"; break; case "dmy": self::$dateFormat = "dd/mm/yy"; break; default: self::$dateFormat = "dd/mm/yy"; break; } }
/** * Constructor * * @param object $controller The controller class * @param string $name The name of the form class * @return object The form */ function __construct($controller, $name) { //FILTER BLOCK 1 : WHERE ARE YOU // Create new group $oFilterField1 = new CompositeField(); // Set the field group ID $oFilterField1->setID('Group1'); // Add fields to the group $oFilterField1->push(new LiteralField('Group1Title', '<div class="filter-title-block">Where are you?</div>')); $oFilterField1->push(new DropdownField('Country', '', Geoip::getCountryDropDown(), 'NZ')); //FILTER BLOCK 2: UPLOAD IMAGE // Create new group $oFilterField2 = new CompositeField(); // Set the field group ID $oFilterField2->setID('Group2'); // Add fields to the group $oFilterField2->push(new LiteralField('Group2Title', '<div class="filter-title-block">When can you help?</div>')); //Set Date Defaults $tToday = mktime(0, 0, 0, date("m"), date("d"), date("Y")); $dToday = date("d/m/Y", $tToday); $tNextMonth = mktime(0, 0, 0, date("m") + 2, date("d"), date("Y")); $dNextMonth = date("d/m/Y", $tNextMonth); //Check if Dates are Set otherwise use Defaults $sFromDate = $this->sFromDate != '' ? $this->sFromDate : $dToday; $sToDate = $this->sToDate != '' ? $this->sToDate : $dNextMonth; //Date Fields $oFromDate = new DatePickerField('FromDate', 'From', $sFromDate); $oToDate = new DatePickerField('ToDate', 'To', $sToDate); $oFilterField2->push($oFromDate); $oFilterField2->push($oToDate); DatePickerField::$showclear = false; // Create new fieldset $oFields = new FieldSet(); // Add the groups to the fieldset $oFields->push($oFilterField1); $oFields->push($oFilterField2); // Create the form action $oAction = new FieldSet(new FormAction('SubmitFilter', 'Find events')); // Add custom jQuery validation script for requred fields Requirements::customScript(' '); // Construct the form parent::__construct($controller, $name, $oFields, $oAction); }