Example #1
0
 protected function updateGetValue($value, $field)
 {
     $name = $field[self::POS_DB_NAME];
     if (isset($field[self::POS_RULE])) {
         if ($field[self::POS_RULE] != '') {
             if ($field[self::POS_RULE] == 'file') {
                 return FileUpload::onUpdate($value, $field, $this);
             }
         }
     }
     if (isset($field[self::POS_RULE])) {
         if ($field[self::POS_RULE] != '') {
             if ($field[self::POS_RULE] == 'date') {
                 $format = ArrayHelper::getValue($field, BaseForm::POS_PARAMS . '.format', '');
                 if ($format != '') {
                     if (StringHelper::startsWith($format, 'php:')) {
                         $format = substr($format, 4);
                         if (!is_null($this->{$name})) {
                             if ($this->{$name} != '') {
                                 $date = \DateTime::createFromFormat($format, $this->{$name}, new \DateTimeZone('UTC'));
                                 return $date->format('Y-m-d');
                             }
                         }
                     }
                 }
                 return '';
             }
         }
     }
     if (isset($field['onUpdate'])) {
         $methodName = $field['onUpdate'];
         return $this->{$methodName}($this->{$name}, $field);
     }
     return $this->{$name};
 }