Esempio n. 1
0
 /**
  * process next attributes:
  * - field1
  * - field2
  * - name
  */
 public function buildOpenTag()
 {
     if (empty($this->attributes['field1']) && empty($this->attributes['field2'])) {
         throw new HtmlTagException('FormDateRange input requires attributes: [field1] and [field2]');
     } else {
         if (empty($this->attributes['field1'])) {
             $this->attributes['field1'] = $this->attributes['name'];
         } else {
             if (empty($this->attributes['field2'])) {
                 $this->attributes['field2'] = $this->attributes['name'];
             }
         }
     }
     $this->processDateAttributes();
     $this->processEnabler();
     $backup = $this->attributes;
     // filter attributes to show only required ones
     $this->attributes = array_intersect_key($this->attributes, array('id' => '', 'name' => '', 'class' => '', 'data-min' => '', 'data-max' => '', 'data-enabler' => ''));
     $this->addClass($this->withTime ? $this->dateTimeClass : $this->dateClass)->setAttribute('data-type', $this->withTime ? 'datetime-range' : 'date-range');
     $this->id;
     //< make id if not set
     unset($this->attributes['name']);
     //< needed only for id
     $openTag = parent::buildOpenTag();
     $this->attributes = $backup;
     return $openTag . $this->getHiddenInput($this->attributes['field1']) . $this->getHiddenInput($this->attributes['field2']);
 }
Esempio n. 2
0
 public function buildOpenTag()
 {
     $this->processDateAttributes();
     $this->processEnabler();
     $backup = $this->attributes;
     // filter attributes to show only required ones
     $this->attributes = array_intersect_key($this->attributes, array('id' => '', 'name' => '', 'class' => '', 'data-min' => '', 'data-max' => '', 'data-enabler' => ''));
     $this->addClass($this->withTime ? $this->dateTimeClass : $this->dateClass)->setAttribute('data-type', $this->withTime ? 'datetime' : 'date');
     $this->id;
     //< make id if not set
     unset($this->attributes['name']);
     //< needed only for id
     $openTag = parent::buildOpenTag();
     $this->attributes = $backup;
     return $this->getHiddenInput($this->name) . $openTag;
 }