[Tickets #14130] monthdayyear form element not saved in DB

noreply at bugs.horde.org noreply at bugs.horde.org
Thu Oct 8 08:41:17 UTC 2015


BITTE NICHT AUF DIESE NACHRICHT ANTWORTEN. NACHRICHTEN AN DIESE  
E-MAIL-ADRESSE WERDEN NICHT GELESEN.

Ticket-URL: https://bugs.horde.org/ticket/14130
------------------------------------------------------------------------------
  Ticket           | 14130
  Erstellt Von     | birnbacs at gmail.com
  Zusammenfassung  | monthdayyear form element not saved in DB
  Warteschlange    | Horde Framework Packages
  Typ              | Bug
  Status           | Unconfirmed
  Priorität        | 2. Medium
  Milestone        |
  Patch            | 1
  Zuständige       |
------------------------------------------------------------------------------


birnbacs at gmail.com (2015-10-08 08:41) hat geschrieben:

I created a ticket type in whups that uses a custom field of type  
monthdayyear but it wouldn't work, i.e. no matter what I entered the  
values were not written into the backend.

I tracked down the bug to the Form module of pear. In Form/Type.php  
the monthdayyear object has a method called _validateAndFormat(). It  
appears that the comparison in line 3021 of $this->_format_in with  
null is using the wrong operator (===). I changed it to == and the  
parameter gets saved to (and retrieved from) the database.

Here is the method in question (fixed version):

    /**
      * Validate/format a date submission.
      */
     function _validateAndFormat($value, &$var)
     {
         /* If any component is empty consider it a bad date and return the
          * default. */
         if ($this->emptyDateArray($value) == 1) {
             return $var->getDefault();
         } else {
             $date = $this->getDateOb($value);
             if ($this->_format_in == null) { // line 3021, changed  
comparison operator from === to ==
                 return $date->timestamp();
             } else {
                 return $date->strftime($this->_format_in);
             }
         }
     }





More information about the bugs mailing list