Source for file jFormsControlDate.class.php

Documentation is available at jFormsControlDate.class.php

  1. <?php
  2. /**
  3. * @package     jelix
  4. * @subpackage  forms
  5. * @author      Julien Issler
  6. * @contributor Thomas, Zeffyr
  7. * @copyright   2008 Julien Issler, 2009 Thomas, 2010 Zeffyr
  8. * @link        http://www.jelix.org
  9. * @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
  10. */
  11.  
  12. /**
  13.  *
  14.  * @package     jelix
  15.  * @subpackage  forms
  16.  */
  17. class jFormsControlDate extends jFormsControl {
  18.     public $type = 'date';
  19.  
  20.     public function __construct($ref){
  21.         $this->ref = $ref;
  22.         $this->datatype = new jDatatypeDate();
  23.     }
  24.  
  25.     function setValueFromRequest($request) {
  26.         $value = $request->getParam($this->ref,'');
  27.         if (is_array($value))
  28.             $value = $value['year'].'-'.$value['month'].'-'.$value['day'];
  29.         if($value == '--')
  30.             $value = '';
  31.         $this->setData($value);
  32.     }
  33.     
  34.     function getDisplayValue($value) {
  35.         if ($value != '') {
  36.             $dt = new jDateTime();
  37.             $dt->setFromString($value, jDateTime::DB_DFORMAT);
  38.             $value = $dt->toString(jDateTime::LANG_DFORMAT);
  39.         }
  40.         return $value;
  41.     }
  42. }

Documentation generated on Wed, 24 Sep 2014 21:59:40 +0200 by phpDocumentor 1.4.3