addDate() public method

Adds a datefield to the form
public addDate ( string $name, mixed $value = null, string $type = null, integer $date = null, integer $date2 = null, string $class = null, string $classError = null ) : FormDate
$name string Name of the element.
$value mixed The value for the element.
$type string The type (from, till, range) of the datepicker.
$date integer The date to use.
$date2 integer The second date for a rangepicker.
$class string Class(es) that have to be applied on the element.
$classError string Class(es) that have to be applied when an error occurs on the element.
return FormDate
Example #1
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     $startDate = '';
     $endDate = '';
     if (isset($this->filter['start_date']) && $this->filter['start_date'] != '') {
         $chunks = explode('/', $this->filter['start_date']);
         $startDate = (int) mktime(0, 0, 0, (int) $chunks[1], (int) $chunks[0], (int) $chunks[2]);
         if ($startDate == 0) {
             $startDate = '';
         }
     }
     if (isset($this->filter['end_date']) && $this->filter['end_date'] != '') {
         $chunks = explode('/', $this->filter['end_date']);
         $endDate = (int) mktime(0, 0, 0, (int) $chunks[1], (int) $chunks[0], (int) $chunks[2]);
         if ($endDate == 0) {
             $endDate = '';
         }
     }
     $this->frm = new BackendForm('filter', BackendModel::createURLForAction() . '&id=' . $this->id, 'get');
     $this->frm->addDate('start_date', $startDate);
     $this->frm->addDate('end_date', $endDate);
     // manually parse fields
     $this->frm->parse($this->tpl);
 }
Example #2
0
 /**
  * Build up the form
  */
 private function build()
 {
     $this->form->addDate('start_date', $this->dateRange->getStartDate(), 'range', mktime(0, 0, 0, 1, 1, 2005), time());
     $this->form->addDate('end_date', $this->dateRange->getEndDate(), 'range', mktime(0, 0, 0, 1, 1, 2005), time());
 }
Example #3
0
 private function loadForm()
 {
     $this->form = new Form('dates');
     $this->form->addDate('start_date', $this->startDate, 'range', mktime(0, 0, 0, 1, 1, 2005), time(), 'noFocus');
     $this->form->addDate('end_date', $this->endDate, 'range', mktime(0, 0, 0, 1, 1, 2005), time(), 'noFocus');
 }